【问题标题】:redirect entire site from http to https except for one page将整个网站从 http 重定向到 https,除了一页
【发布时间】:2018-05-12 22:48:07
【问题描述】:

我想将我的整个网站从 http 重定向到 https,除了一页(实际上是要下载的文件),但我遇到了麻烦

我正在使用

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

从这篇文章...htaccess redirect to https://www

但还没有弄清楚如何排除我需要的一个文件。

或多或少

http://www.something.com/phone/version/currentversion.txt

我尝试将它的 https 版本重定向回 http 版本,但我收到一条错误消息,表明我处于无限循环的解析中并且无法正常工作

任何帮助将不胜感激

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    一个简单的 mod_rewrite 异常应该可以工作:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !/phone/version/currentversion.txt
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    【讨论】:

    • 没问题。我很高兴听到。 :)
    猜你喜欢
    • 1970-01-01
    • 2013-07-03
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多