将IP地址重定向到域名 [英] Redirect IP address to domain name

查看:62
本文介绍了将IP地址重定向到域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定是怎么发生的,但谷歌已经通过 IP 地址和域名索引了我的网站在 Google 的某些搜索中,我看到我的网站类似于 121.12.12.123/tech/tech.php.

Not sure how it happened, but Google has indexed my site both by IP address and domain name and in some search in Google I see my site like 121.12.12.123/tech/tech.php.

请告诉我如何将其重定向到我的域?

Please let me know how can I redirect it to my domain?

121.12.12.123    redirect to   www.mydomain.com
121.12.12.123/*  redirect to   www.mydomain.com/*

推荐答案

如果您的站点在 apache 网络服务器上运行,您可以使用 mod_rewrite 并把这样的东西放在你的 .htaccess 中:

If your site is running on a apache webserver, you could use mod_rewrite and put something like this in your .htaccess:

RewriteCond %{HTTP_HOST} ^121\.12\.12\.123
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

这篇关于将IP地址重定向到域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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