将多个域转发到一台 Web 服务器(对 SEO 友好)的最佳技术是什么?
设置是:
- www.domainA.com
- www.domainB.com
实际上都托管在一台 Web 服务器上(Apache)
- 123.123.123.123/domainA
- 123.123.123.123/domainB
我已经设置了从域到 Web 服务器目录的隐藏转发,该目录有效然而,fine 会产生重复的内容(因为它也可以通过直接寻址 Web 服务器来获得)。我尝试为每个直接针对 IP 地址的请求(使用 mod_rewrite)设置 301 重定向到域,但发现这会导致转发循环。显然,服务器无法识别该域最初是否已被请求。
如果有人能给我一个关于如何完成此操作的提示,我会很高兴听到。
The setup is:
- www.domainA.com
- www.domainB.com
both actually hosted on one web server (Apache)
- 123.123.123.123/domainA
- 123.123.123.123/domainB
I have setup a hidden forward from the domains to the web server directories which works fine, however, produces duplicate content (since it is also available by addressing the web server directly). I tried setting up 301 redirects to the domains for every request that is targeting the IP address directly (using mod_rewrite),but found that this results in a forwarding loop. Obviously the server does not recognize whether the domain has been requested originally.
If anybody can give me a hint on how this is supposed to be done, I'd be glad to hear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在网络服务器上设置虚拟主机,以便它关注所请求的主机名。这是一种相当常见的做法,应该可以解决您的问题。您可以取消单独的子目录,因为每个虚拟主机都有自己的虚拟根目录。
You can set up virtual hosting on the web-server so that it does pay attention to the hostname that was requested. This is a fairly common practice and should solve your problem. You can do away with separate subdirectories since each virtual host has its own virtual root.
那么您是说您的 Google 索引页面引用了您的 IP 地址和目录而不是域名吗?
另外,我不确定为什么从 IP 重定向到域名会导致重定向循环。如果重定向基于主机标头,则应该可以正常工作。
So are you saying that you have pages indexed in google that reference your IP address and a directory rather than the domain name?
Also, I'm not sure why doing a redirect from the IP to the domain name would cause a redirect loop. If the redirect is based on the host header, it should work fine.