301 Redirect where 2 domains point to same IP?

老子叫甜甜 提交于 2019-12-06 09:34:47

I would do it like this:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

That will redirect (statuscode 301 "permantly moved") every domain which is not www.example.com to www.example.com.

phihag

The 301 redirect you posted is just fine; the HTTP header of every request (nowadays) contains the name of the host.

As an alternative, you can use rel=canonical. It's not that urgent anyway, as duplicate content on just two domains is unlikely to be a problem.

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