【问题标题】:Prevent htaccess from redirecting IP's to www防止 htaccess 将 IP 重定向到 www
【发布时间】:2016-05-13 17:11:50
【问题描述】:

我们有这个 htaccess 代码可以将非 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”,网站将无法加载。 我们该怎么办?

【问题讨论】:

    标签: linux apache .htaccess mod-rewrite rewrite


    【解决方案1】:

    您可以使用以下条件来停止对 HTTP_HOST ip 地址的重定向:

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

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      • 2011-04-12
      • 2015-12-31
      • 1970-01-01
      • 2017-05-03
      • 2012-10-19
      • 2017-02-12
      相关资源
      最近更新 更多