.htaccess permanent redirect to www

admin

Administrator
Staff member
I have a wordpress instalation that is not redirecting urls not starting with www.

Example: <a href="http://example.com/dir/" rel="nofollow">http://example.com/dir/</a> doesn't send to <a href="http://www.example.com/dir/" rel="nofollow">http://www.example.com/dir/</a> instead goes to <a href="http://example.com/" rel="nofollow">http://example.com/</a>

How do I change the .htaccess below to always redirect to the page either using www or not?

Code:
# BEGIN WordPress
RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

# END WordPress