I have installed wordpress at the root (httpdocs).
When I enter domain url wordpress theme loads.
All ok, except that for now I would like that my old static index.html page is loaded instead, and that I can access wordpress with direct URI ...like /index.php
I think I need to modify .htaccess somehow for this to work? somehow I am not successfull at this. Maybe something needs to be reconfigured in wordpress as well?
I would appreciate some experts help.
Thanks!
Put something like
RewriteEngine On
RewriteRule ^$ /index.html [L]
before the Rules added by WordPress (before # BEGIN WordPress). This will match the request for / (and only that) and rewrite it to /index.html. The L flag indicates that no other rules shall be executed.
To give logged in WP users the WP site instead of your static page, use
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !wordpress_logged_in
RewriteRule ^$ /index.html [L]
But why don't you just convert your static home page into the front-page for WordPress? See the documentation for more info and examples.
Related
I want to make a better link shortener service using YOURLS. I've procured a short URL for this: sly.pe. YOURLS is installed and sly.pe/admin is accessible.
I'd also like to use WordPress to power most of the consumer facing site, at the URL: sly.pe. The idea being I want users to register for the site using WordPress and a registration plugin like OneAll social. Once authenticated they get logged in for both YOURLS and WordPress and are redirected to a URL like sly.pe/home that uses WordPress as the site but YOURLS (sly.pe/admin for that user) is embedded and accessible somehow.
Both services make .htaccess changes. If I leave the file as is, I can't seem to have any other WordPress URL other than sly.pe, but YOURLS works fine. If I comment out some YOURLS code, WordPress can use other directories, but then YOURLS doesn't work. How can I have both coexist nicely? Or at least define the WordPress URLs I want and get those working?
(commenting out the YOURLS code gets WordPress working, but breaks YOURLS):
.htaccess:
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I was able to get YOURLS to work with WordPress. Here's how I did it...
I've placed YOURLS in niemannross.com/links - so for me, a redirect looks like http://niemannross.com/link/rlunchlessons
Install the Redirection plugin by John Godley in your copy of WordPress.
Look in Wordpress:Admin:Tools:Redirection. Across the top are several tabs. You should see Redirects | Groups | Logs | 404s | Import/Export | Options | Support.
Choose Redirects
Select Add New Redirection
Source URL: /link/.* - Select Regex.
Target URL: /link/yourls-loader.php
Group: Whatever makes sense in your setup. I've chosen wordpress:redirections
This works for my installation.
Simple answer is: you cannot. Both WordPress and YOURLS (please, YOURLS, not YourLS) need to process server requests to return the expected result (eg when requesting http://sho.rt/blah, each app needs to check if blah is content it manages)
Long answer: you should not because all of the following.
Basically you would need something that works when:
blah is an WP article but not a YOURLS short URL
blah is a YOURLS short URL but not an WP article
blah is neither a WP article or a YOURLS short URL
optionally decide what to do when blah is both a WP article and a YOURLS short URL
Your code would also need to :
prevent WP to create a "slug" that is already a YOURLS short URL
prevent YOURLS to create a short URL that already matches a WP slug
You'd need to have code for this both in the WP area and in the YOURLS area.
Bottom line: lots of edge cases to deal with. What might work in some case on your side might not work in other cases, on your side or with others.
I think you're going to have to work around the problem as mentioned by #Ozh, but here's a plugin that will make it easier for your WordPress users to use YOURLS: https://wordpress.org/plugins/yourls-link-creator/
You cannot, I tried different ways, maybe with new apache 2.4 using the if else statement you will, but I am not an expert on those commands, I want to share what I did to have the shortener option in the root page and the html site in a subdirectory, with this solution you can still give people normal url for the website (e.g. sho.rt):
set your website in a folder under root with a name e.g. "w", that means it will be at "sho.rt/w"
then use this .htaccess
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
RewriteRule ^$ /w [L]
</IfModule>
# END YOURLS
This will give you the option to still use sho.rt as your website address if the user doesn't pass any subfolder in the url, but if they do, it will check in yourls first and go to your folders if nothing found.
One more thing, do not forget to add "w" in the $yourls_reserved_URL array in /user/config.php (Yourls config file)
I finally solved this for my website.
I have a subdomain http://sub.domain where I installed YOURLS, but the short URLs are at http://domain/someshortlink
And the wordpress website is also at http://domain/
It used to work with the swap plugin ( https://github.com/gerbz/Yourls-Swap-Short-Url ).
Just with the htaccess provided by that YOURLS plugin, and no wordpress. But since I decided to move to wordpress, this combination won't work.
Here is the trick:
On your htaccess, keep it simple, as wordpress wants it to be. Remove the snippet htaccess for the YOURLS swap plugin, if you have it added.
Edit your 404.php page theme. Mine was at: wp-content/themes/twentynine/404.php
At the very begin, just add:
<?php
header('Location: http://sub.domain' . $_SERVER['REQUEST_URI'] );
exit;
?>
This will allow:
All files and directories will honor the basic htaccess from which they are simply served
All URLS not files and folders will be handled by wordpress in the usual manner.
If a page is not found, wordpress will trigger 404.php which will send that page to YOURLS to try
If YOURLS also don't find it, a 404 page from YOURLS will show.
Remember to edit the 404 page from YOURLS also, to match your wordpress theme.
Best of luck!
Reference: https://github.com/gerbz/Yourls-Swap-Short-Url/issues/11
I'm in a siutation where I need static pages to take over for much of a wordpress site I'm working with. I have created a /static directory in order to hold the static pages, but I also need to keep the exiting blog visible. I have the following code in my .htaccess file:
RewriteEngine On
RewriteRule ^blog index\.php [L]
RewriteRule ^20* index\.php [L]
RewriteRule ^$ static [L]
Going to mydomain.com/blog or mydomain.com/2014/01/blog-post both work, but if I try to go to mydomain.com the URL is being redirected to mydomain.com/static which is not what I am trying to accomplish.
Additionally, trying to visit any other page such as mydomain.com/about.php throws a 404 error which makes me think my rewrite is entirely wrong. Essentially I want all requests except for the blog page and blog posts to be rewritten to the files in /static
You need a trailing at the end of the directory or else mod_dir and DirectorySlash will redirect the browser to the URL with the trailing slash. So you're 3rd rule needs to be:
RewriteRule ^$ static/ [L]
Im running a WordPress site with qTranslate installed.
The URLS are currently displayed as http://domain.com/en/ but i would like to change them to
http://en.domain.com
How do i make this work? qTranslate has a built-in pre-domain mode, which should do exactly what i need. But all it does is change the links (works), when visiting the page i get a 404 error.
In the admin it says "Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!"
I got pre-path working and i think im using pretty permalinks (/%category%/%postname%/), but ive got no idea what kind of 'additional configuration' is needed.
My .htaccess looks like this (i think standard wp output);
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I tried a lot of different things found online, but i mostly get internal server errors or just the 404.
Thanks in advance!
If your default url starts with www (like www.domain.com) then your translated urls will look like en.www.domain.com.
But if you try to login en.domain.com, you may think that your plugin doesn't working.
Before try anything be sure that any subdomains shows your WordPress homepage. With default settings WordPress should not redirect to you anywhere.
Then set your default url without www prefix (for ex. domain.com)
And check the permalink finally
If you fail at any steps, disable all plugins and even change your theme to default one.
You'd have to add wildcard domain setting at your DNS settings for the domain. https://codex.wordpress.org/Configuring_Wildcard_Subdomains‎
Wildcard domain redirect with WordPress See also this post.
I have a working Fishpig Wordpress Magento instance on a production server.
All the green ticks show it has succesfully configured and when visiting
http://www.example.com/blog
it works. However when I try and and visit
http://example.com/blog
it sends me back to the magento home page at www.example.com .
I have tried setting the url in wordpress to both http://example.com/blog and http://www.example.com/blog but in both situations it always sends me to the home page at site.com.
This is a concern because most experienced web users will not type www when trying to access a location.
My htaccess is as generated by Wordpress and looks like
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
#wp generated
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Please not the wordpress site files are located at site.com/wp and it is the fishpig extension which arranges the direct from the non existent /blog path.
First of all, to start of, one way to resolve the issue is to simply make your Magento website DEFAULT to not have the www. in the url.
In Magento, go to System > Configuration > Web.
In the "Secure" and "Unsecure" tabs, find "Base URL."
The value should look something like this:
http://www.site.com/
Replace ALL references to the domain so it shows:
http://site.com/
Unfortunately, there may be a lot of appearances of it throughout the site. You'll need to do the same thing elsewhere on the server.
If you really want your site/blog to say www., though, you'll have to properly forward the .htaccess file in Magento. I'm not too keen on how Magento's .htaccess file works, but I do know how to forward a url and keep all of its additional pages as well (however, Magento's setup may interfere).
The code should look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.site.com$1 [R=301,L]
Again, I don't know how well this will work with Magento's set up, but I've successfully used the above code to redirect url's to the correct url I want. That code above was actually used on a wordpress site, though.
Check for Rewrite rules in Magento's .htaccess file and try putting this above it. Be careful, though; it is VERY easy to cause 500 internal server errors if you mess up the .htaccess file, so always keep a backup.
Try this out and I hope it helps.
I have a site made with CodeIgniter with a WordPress site at /blog.
Say I create a page in WordPress that can be viewed at /blog/my-page.
Is it possible to rewrite the URL with .htaccess to remove the blog part of the URL? So I could enter my site url /my-page to view the page?
from the top of my head..
#start the engine
RewriteEngine on
#requests to www.yourpage.com/anything/
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$ [NC]
#are sent to www.yourpage.com/blog/anything/
RewriteRule .* /blog/%1 [L]
The rule below will rewrite (internal redirect) /my-page to /blog/my-page:
RewriteEngine On
RewriteBase /
RewriteRule ^my-page$ /blog/my-page [NC,L]
RewriteRule ^another-page$ /blog/another-page [NC,L]
This needs to be placed in .htaccess in website root folder.
If you already have some rewrite rules there then this one need to be placed in appropriate place as order of rules matters.
You still may need configure WordPress a bit so it understands that this URL is for him to process (WordPress may still see the original URL). I have not worked with WordPress that much to tell if this will be required (and how to do it if it is) -- but look at Permalinks settings.