mod_rewrite有例外

时间:2010-10-26 08:02:02

标签: apache mod-rewrite

为了将我服务器上的每个请求重定向到安全连接,我使用

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://mywebsite.com/$1 [R,L]

完美无缺。

但是我需要两条路径不被重定向。

说我何时访问

http://www.mywebsite.com/page1/test
http://www.mywebsite.com/page2

我想要走那条路。用mod_rewrite可以吗?

1 个答案:

答案 0 :(得分:11)

尝试这样的事情:

RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !/page1/test
RewriteCond %{REQUEST_URI} !/page2
RewriteRule ^(.*)$ https://mywebsite.com/$1 [R,L]