使用 .htaccess 重定向
我刚刚更换了服务器,我的网站使用了新的 IP 地址。我猜这个IP地址的前任所有者仍然有他的域名指向我的IP。因此,当您访问他的域名时,我的网站就会显示出来。他无法进行更改或类似的操作,但这会扰乱我的搜索引擎排名。我想知道我是否可以使用 htaccess 将他的域名重定向到我的域名,这样的话
if(his domain){ 重定向到我的网站 当然
,您不能在 .htacess 中使用类似的 if 语句,但您明白我的意思了。
谢谢
I just switched servers and my site is on a new ip address. I guess the previous owner of this ip address still has his domain pointing to my ip. So when you go to his domain name my site shows up. He can't make changes or anything like that, but it's messing with my search engine rankings. I was wondering if I can us htaccess to redirect his domain to mine so something like this
if(his domain){
redirect to my site
}
of course you can't use if statements like that in .htacess but you get my drift.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题不完全清楚。根据我的理解,因为这不是 mod_rewrite 问题,这里是我的答案:
公共IP是唯一的,希望您将域名和IP混淆。如果你的域名指向你的服务器IP,就不会有任何问题。但是,如果两个域托管在同一服务器(ip)上,那么您可以使用虚拟主机配置来指向类似于 ReverseProxy ProxyPass 的正确站点。
如果搜索引擎当前使用旧 IP 地址对您的网站页面建立索引,那么您别无选择。您可能会触发搜索引擎重新索引。
Question is not fully clear. Based on my understanding as it is not mod_rewrite question, here my answer:
Public ip is unique and hope you mixed up with domain name and ip in question. If your domain pointed to your server ip, there should not be any problem. However if both domains hosted on same server(ip), then you could use virtualhost config to point to correct site similar to ReverseProxy ProxyPass.
If search engines currently indexed your site pages with old ip address, then no choice there for you. You may trigger search engines to re-index.