【问题标题】:Redirecting from https to http with the exception of some URI's从 https 重定向到 http,但某些 URI 除外
【发布时间】:2013-04-10 12:17:19
【问题描述】:

所以我目前遇到的问题是我们的整个网站都是使用 https 进行索引的。我们想使用 .htaccess 重定向到 http。问题是我们需要几个 URI 才能仍然使用 https,我不确定如何为 URI 编写异常

我知道如果我们的网站像 www.example.com/account.php 那样运行,但我们的网站网址像 www.example.com/index.php?l=account

# Turn SSL on for account
RewriteCond %{HTTPS} off
RewriteCond %{SCRIPT_FILENAME} \/account\.php [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

我该如何解决这个问题,任何指导将不胜感激。

谢谢

编辑!

所以下面的这段代码我已经工作了,但我想再做一个我似乎无法工作的异常,我还希望根 (index.php) 只使用 http。

我尝试使用...

RewriteCond %{REQUEST_URI} !^/index.php 

但这不起作用

# invoke rewrite engine
RewriteEngine On
RewriteBase /

RewriteCond %{https} off
RewriteCond %{QUERY_STRING} !^l=product_detail
RewriteCond %{QUERY_STRING} !^l=product_list
RewriteCond %{QUERY_STRING} !^l=page_view
RewriteRule ^(.*)$ https://%{HTTP_HOST}/development/$1 [R=301,L]

谢谢

【问题讨论】:

    标签: .htaccess redirect https uri


    【解决方案1】:

    试试

    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^/account.php 
    RewriteCond %{QUERY_STRING} !^l=account
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
    
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} ^/account.php [OR]
    RewriteCond %{QUERY_STRING} ^l=account
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2017-05-30
      • 2023-03-17
      • 2014-03-19
      • 1970-01-01
      • 2016-05-01
      • 2012-04-02
      • 2016-05-26
      • 1970-01-01
      • 2017-11-15
      相关资源
      最近更新 更多