【问题标题】:htaccess Redirect https for specific directoryhtaccess 为特定目录重定向 https
【发布时间】:2015-11-24 11:22:40
【问题描述】:
我正在努力实现以下目标:
这是我所拥有的,但它给了我一个循环。
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]