【问题标题】:Is it possible to redirect specific pages of my website (using https) to http?是否可以将我网站的特定页面(使用 https)重定向到 http?
【发布时间】:2021-03-29 20:19:44
【问题描述】:

瞄准

我想将我网站的特定页面重定向到 http。

背景

我有以下 .htacess

Options All -Indexes
RewriteEngine On 
RewriteRule ^(.*)\.html $1\.php [L]
RedirectMatch ^/*$  https://**mydomain_name**/files/index.php   
Options +SymLinksIfOwnerMatch 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /files/error.php [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

这允许我将所有内容重定向到 https(这很好用)

问题

是否可以将地址包含 internal (https://mydomain_name/internal/) 的所有页面重定向到 http(而不是 https)?

【问题讨论】:

    标签: apache .htaccess http mod-rewrite url-rewriting


    【解决方案1】:

    我们可以保持条件不处理包含内部的 URI 的请求,而不是首先将它们重定向到 https,然后针对特别提到的 URI 移回 http。

    Options All -Indexes
    RewriteEngine On 
    RewriteRule ^(.*)\.html $1\.php [L]
    RedirectMatch ^/*$  https://**mydomain_name**/files/index.php   
    Options +SymLinksIfOwnerMatch 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /files/error.php [L]
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} !^/internal [NC]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    

    【讨论】:

    • 太棒了!我没有 RewriteCond %{REQUEST_URI} !^/ [NC]
    • 很好的答案 RavinderSingh !
    猜你喜欢
    • 2013-07-03
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多