繁体   English   中英

防止htaccess将IP重定向到www

[英]Prevent htaccess from redirecting IP's to 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]

该网站具有专用IP,当我们输入IP地址时,重写引擎会将“ 107.180.56.244”重定向到“ https://www.107.180.56.244 ”,并且该网站将无法加载。 我们应该做什么?

您可以使用以下条件来停止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