我有2个顶级域名 example.com
和 example.ie
。
example.com
和 example.ie
这两个点在同一IP地址,现在拉相同的内容,我们可以从谷歌禁止锤重复的内容让疲惫不堪,所以我们希望任何人访问 *。example.ie
和 *。example.com
被重定向到 www.example.com
的问题是,因为它们都指向同一个服务器上的.htaccess是一样的。因此,我不相信我们可以做平常:
example.com
and example.ie
both point at the same IP address and pull the same content now we could get whacked with a ban hammer from Google for duplicate content so we want anyone accessing *.example.ie
and *.example.com
to be redirected to www.example.com
the problem is as they are both pointing at the same server the .htaccess is the same thus I don't believe we can do the usual:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
那么,我们如何去从 *。example.ie
和 *。example.com 到
www.example.com
?
我会做这样的:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
这将重定向(状态code 301permantly移动)的每个域是不可以 www.example.com到www.example.com。
That will redirect (statuscode 301 "permantly moved") every domain which is not www.example.com to www.example.com.