.htaccess and WordPress
When installing WordPress for this blog, I stumbled across this problem: I couldn't get 301 redirection to forward the www.ekstreme.com version to the ekstreme.com version of the site if accessing the /thingsofsorts/ directory. After some playing, this is how to do it.
The default .htaccess that comes with WordPress is:
RewriteEngine On
RewriteBase /thingsofsorts/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /thingsofsorts/index.php [L]
The simple modification is this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.ekstreme\.com [nc]
RewriteRule (.*) http://ekstreme.com%{REQUEST_URI} [R=301,L]
RewriteBase /thingsofsorts/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /thingsofsorts/index.php [L]
Nice and simple. You can read more about 301 redirection and SEO in my 301 redirection tutorial; it even includes code examples!
Technorati Tags: 301 redirection, Apache, WordPress, blog
Subscribe to Things of Sorts
If you liked this post, please subscribe to the Things of Sorts RSS feed: ![]()
