【问题标题】:htaccess Redirect https for specific directoryhtaccess 为特定目录重定向 https
【发布时间】:2015-11-24 11:22:40
【问题描述】:

我正在努力实现以下目标:

  • 将所有 WWW 请求重定向到等效(不带 WWW)

  • 将所有 HTTPS 请求重定向到 HTTP

  • 将所有请求重定向到子目录 /cart 以强制使用 HTTPS

这是我所拥有的,但它给了我一个循环。

RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(cart/.*)$ https://example.com/$1 [R,L]
RewriteRule ^(.*)$ http://example.com/$1 [R,L]

【问题讨论】:

    标签: .htaccess redirect https directory


    【解决方案1】:
    RewriteEngine On
    
    #www to non-www
    RewriteCond %{HTTP_HOST} ^www\. 
    RewriteRule ^(.*)$ http://example.com/$1 [R,L]
    
    #https to http
    RewriteCond %{HTTPS} ^on$
    RewriteRule ^(.*)$ http://example.com/$1 [R,L]
    
    #if the request is for /cart then enable https 
    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{REQUEST_URI} ^/cart
    RewriteRule ^(.*)$ https://example.com/$1 [R,L]
    

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 1970-01-01
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-19
      相关资源
      最近更新 更多