301重定向,其中2域指向同一个IP? [英] 301 Redirect where 2 domains point to same IP?

查看:203
本文介绍了301重定向,其中2域指向同一个IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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.

这篇关于301重定向,其中2域指向同一个IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆