views:

27

answers:

2

i want to redirect domain domain1.com to domain2.com completely but without changing domain1.com URL. i thought i could do that with .htaccess but i found out that it is not possible because they are to different domains and i should use http:// in .htaccess rule so it would be an external rewriting not an internal rewriting,so the URL will change.

is there any other solution? is using iframe the only solution? i have to add that i don't want to change DNS setting for these 2 domains.

A: 

If they run on the same webserver you could set domain2 as an ServerAlias for domain1.

I thought I once read you could give a flag to mod rewrite that it internally proxies the request to another domain, however I have never used this myself (if it even exists) and I can't honestly say I think it'll be great for performance.. (but maybe it is..)

But why would you want two different domains show the exact same website, without changing the hostname to, what you see as, the primary one. If I might ask?

CharlesLeaf
+1  A: 

If both domains point at the same server then you can setup your apache config to point both domains at the same document root.

NameVirtualHost *

<VirtualHost *>
ServerName domain1.com
DocumentRoot /www/mysite
</VirtualHost>

<VirtualHost *>
ServerName domain2.com
DocumentRoot /www/mysite
</VirtualHost>

However, I would recommend domain2.com redirects (with a 302 redirect in the .htaccess) because it will improve your search engine optimisation, as both sites will be considered as one. So if a GoogleBot finds domain2.com as a link in another site, it will add it as a pagerank to domain1.com.

Codemwnci