Rewriting urls with mod rewrite and .htaccess, and wordpress.

Every time I do anything on this blog I run into this problem.  UK2 (who host me) have one public_html folder for, and then subfolders for and my other domains.  This is just the way the product is structured – the other domains are addons to the original.

But the problem with it is that I can easily choose where the other domains get their source from.  So I can easily change to look in public_html/polargraph_newsite if I want to test something new out.  But it’s not as easy to redirect visitors to this site (, because the main domain can’t be treated that way, it seems.  I don’t pretend to understand why.

So I have this site running in a subdirectory (public_html/ev3), and use following mod_rewrite rules in the .htaccess file to rewrite the incoming urls:

Options +FollowSymlinks
RewriteEngine on
IndexIgnore *

RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/ev3/
RewriteRule ^(.*)$ /ev3/$1
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ ev3/index.php [L]

In this case, because I installed wordpress into, all of the urls in the site pointed there as the root, instead of to  This exasperated me in the past, and every time I’ve done this, because I thought there was some rewriting magic going on.  But it’s dead simple, it’s just the root domain name settings in wordpress itself (admin->settings->general->wordpress address and site address).  DUH.

Leave a Reply

Your email address will not be published. Required fields are marked *