【发布时间】:2015-05-19 14:14:29
【问题描述】:
我对 apache 的重定向设置感到困惑。看起来很简单,但我想不通……
http访问下
if carts/ and events/* need to redirect to https
我在 sites-enabled/default-http.conf 中添加此设置
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/carts/ [OR]
RewriteCond %{REQUEST_URI} ^/events/*
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</ifModule>
https访问下
if not carts/ and events/* need to redirect to http
我在 sites-enabled/default-https.conf 中添加此设置
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !(^/carts/) [OR]
RewriteCond %{REQUEST_URI} !(^/events/*)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</ifModule>
问题是这样的
http 运行良好,但 https 不起作用。
https://test.com/test 应重定向到 http://test.com/test
【问题讨论】:
-
感谢您的回复。我添加了 *.conf
-
我添加了一个问题 :-)
标签: regex apache mod-rewrite redirect https