apache重写困境

时间:2011-08-23 12:14:33

标签: apache mod-rewrite ssl

1 个答案:

答案 0 :(得分:2)

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

你不能在这里使用默认的AND逻辑重写条件 - 它必须是OR逻辑(用简单的英语阅读你的条件,你会看到缺陷 )。

两种方法:

1。明确指定应使用OR逻辑:

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php [OR]
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

2. 将两个重写条件合并为一个(使用OR逻辑):

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/(visit_us|social)\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]