简体   繁体   English

防止htaccess将IP重定向到www

[英]Prevent htaccess from redirecting IP's to www

We have this htacceess code to redirect non-www URL's to https://www : 我们有此htacceess代码可将非www URL重定向到https:// www

#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The website has dedicated IP and when we enter the IP address , Rewrite engine will redirect "107.180.56.244" to " https://www.107.180.56.244 " and the site will not load. 该网站具有专用IP,当我们输入IP地址时,重写引擎会将“ 107.180.56.244”重定向到“ https://www.107.180.56.244 ”,并且该网站将无法加载。 What should we do? 我们应该做什么?

You can use the following conditions to stop the redirection for HTTP_HOST ip address : 您可以使用以下条件来停止HTTP_HOST IP地址的重定向:

RewriteCond %{HTTP_HOST} !^(\d+)
RewriteCond %{HTTP_HOST} !^www\.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM