重定向I​​P域 [英] Redirect IP to domain

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

问题描述

谷歌搜索结果显示我的页面作为(IP)/mypage.html代替的https:// WWW .mydomain.com /的mypage.html 。我认为,解决的办法是重定向IP的域。我发现很多非常相似的方式来做到这一点,但他们都不是为我工作。我有一个重定向HTTP到HTTPS现有规则。这是我的.htaccess文件目前是这样的:

Google search results are showing my pages as (ip)/mypage.html instead of https://www.mydomain.com/mypage.html. I believe the solution is to redirect the ip's to the domain. I've found many, very similar ways to do this, but none of them are working for me. I have an existing rule that redirects http to https. This is what my .htaccess file currently looks like:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

我是什么做错了吗?

What am I doing wrong?

推荐答案

您2重写条件冲突。它们需要HTTP_HOST是11.11.11.111并成为* .mydomain.com,在同一时间。只需添加一个或像这样:

Your 2 rewrite conditions clash. They require http_host to be 11.11.11.111 and to be *.mydomain.com, at the same time. Just add an or like so:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

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

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