Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have the following in a .htaccess file:

RewriteCond %{HTTP_HOST} ^www\.aliasdomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^aliasdomain\.com$
RewriteRule ^(.*)$ [R]

In a browser I want to access the index.html file and show up as

However it shows up as the full URL as follows:

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to internally rewrite the request in order to keep in the browser, and not externally redirect as you are currently doing...

Remove the protocol/host from the RewriteRule substitution, to leave just a root-relative path, and remove the R (redirect) flag. The protocol/host in the substitution forces an external redirect.

RewriteCond %{HTTP_HOST} ^(www\.)?aliasdomain\.com$
RewriteRule ^$ /subdir1/subdir2/index.html [L]

The ^$ pattern in the RewriteRule directive ensures that only requests for the domain root (ie. or gets rewritten to the new URL, rather than (as mentioned in the comments below).

Since is a domain alias of, the entire site is accessible via both domains. They point to the same place. This is what the above rewrite rules are dependent upon. You can't internally rewrite to a different host. So the above RewriteRule serves the file from

share|improve this answer
Oops, thanks for this and I'm sure you are on the right track but I got an "Internal Server Error". – Michael Aug 16 '13 at 7:23
Sorry, yes - a second RewriteCond directive is required in order to prevent a rewrite loop. I've updated the code. – w3d Aug 16 '13 at 11:00
Thanks again. Now getting the following error: Content Encoding Error The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression. – Michael Aug 16 '13 at 12:44
I'm pretty sure that error is not related to this current issue. Can you access directly in your browser? Are you using Firefox? – w3d Aug 16 '13 at 13:10
I can access directly. but not the link you have given. – Michael Aug 16 '13 at 13:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.