Posts Tagged ‘mod_rewrite’

URL-Rewriting a domain into a sub-directory

Thursday, December 9th, 2010

Just yesterday I moved my WordPress blog to GreenGeeks.com;
Since I wanted to have the URL shortened, I created this .htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^codefx\.biz [OR]
RewriteCond %{HTTP_HOST} ^www\.codefx\.biz [NC]
RewriteRule ^(.*)$ wordpress/$1 [L]

The .htaccess file inside the WordPress directory also needs to handle the rewritten URL:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . wordpress/index.php [L]

This might apply to other cPanel managed web-servers, as well as GoDaddy.