View Full Version : masked redirect with htaccess

04-07-2011, 05:55 PM
Hi all,
I have multiple domains on my hosting and I basically want to redirect users from my public_html folder to a subfolder (public_html/mydomain.co.uk) but I don't want the URL bar to show mydomain.co.uk/mydomain.co.uk so I need to use htaccess to do a masked redirect.

The code I have so far is:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} mydomain.co.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/mydomain.co.uk/.*$
RewriteRule ^(.*)$ /mydomain.co.uk/$1 [L]

This code works fine if the user simply navigates to www.mydomain.co.uk, it redirects to the /mydomain.co.uk subfolder but still keeps www.mydomain.co.uk in the URL bar.

However if the user navigates directly to www.mydomain.co.uk/services for example, the redirect still works but the URL bar displays www.mydomain.co.uk/mydomain.co.uk/services

How can I alter the htaccess code to make sure the redirect is masked for all subfolders?