Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Similar to question posted here (but not related to sub directories): .htaccess redirect of domain name alias to main domain but must show up as the alias domain

I am trying to direct traffic from an alias domain I have to my site that is on the same server, while also keeping the alias domain in the browser address bar.

This is my original htaccess content which correctly redirects the user, but xyz.com appears in the browser which I do not want.

rewritecond %{HTTP_HOST} ^(www\.)?abc\.com$ [NC]
rewriterule ^ http://xyz.com/?foo [R=301,QSA,L]

This is my attempt to not only bring abc.com visitors to xyz.com but also have abc.com appear in the browser. This doesn't even load the site. Any ideas on a fix?

rewritecond %{HTTP_HOST} ^(www\.)?abc\.com$
RewriteRule ^$ /index.html [L]
share|improve this question
    
Can you modify the DocumentRoot of the alias domain? If you point that to the same path as the "main domain"" you can do it without the RewriteRule-stuff. If you can't change that, then you have to use RewriteRules, in that case you probably have to replace /index.html with the correct relative path. So if, for example, the index.html of the main-domain is in the directory above you have to write ../index.html. –  vstm Sep 28 '13 at 15:47
    
No access to DocumentRoot. abc.com is in a folder called aliasdomains and index.html is simply in the root folder so that is why I just wrote it as /index.html. Is my RewriteRule above still in an incorrect format? –  John Montague Sep 29 '13 at 1:47
    
With RewriteRules you can't "break out" of the DocumentRoot, that means you can only point to files/folders inside your DocumentRoot and not in one of it's parent folders. So /index.html points to /path/to/aliasdomains/index.html (my solution with ../index.html wouldn't work either). You could just copy or symlink the file from the root folder to your aliasdomains folder. If that's not possible and your apache comes with the proxy module, you could do a proxy-rewrite with RewriteRule ^$ http://xyz.com/index.html [L,P]. –  vstm Sep 29 '13 at 8:25
    
Problem resolved. As per @vstm comments I realized constraint on the folder hierarchy. I simply moved abc.com out of the aliasdomains folder and put it in the hosting root folder. Thanks. –  John Montague Sep 29 '13 at 14:45
    
Since you resolved the problem, so that this question doesn't remain unanswered, please answer it below and select your answer when you can. –  dan Oct 4 '13 at 11:42

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.