[英]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.