redirecting without changing URL

拥有回忆 提交于 2019-12-02 04:20:58

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.

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!