防止 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\.
我们有这个 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\.