views:

35

answers:

1

This is my .htaccess generated by wordpress that sits in my root directory.

I need to modify/add to it, to direct all incoming traffic to www.example.com, instead of example.com.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If someone wants to explain what all the above does also, that would be appreciated as well.

+3  A: 

To do what you requested, you want to add:

RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC] 
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]

You can place that inbetween the <IfModule mod_rewrite.c> brackets after RewriteBase

As for what Wordpress' htaccess code does (didn't test it): It seems to test for any direct links to files and directories and not pass them through the RewriteRule which will normally take your link and send it to index.php

So if your link is for www.mysite.com/some/page, it makes sure /some/page isn't a direct file link or an actual web directory and if it isn't, then it passes the request to index.php which parses it to display the correct Wordpress page.

Bartek