开发者

mod_rewrite with exceptions

开发者 https://www.devze.com 2023-01-21 05:05 出处:网络
For redirecting every request on my server to a secure connection I use RewriteCond %{SERVER_PORT} 80

For redirecting every request on my server to a secure connection I use

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

which works perfect.

However I need two paths not to be redirected.

Say when I access

http://ww开发者_运维技巧w.mywebsite.com/page1/test
http://www.mywebsite.com/page2

I want to go to exactly that path. Is that possible with mod_rewrite?


Try something like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消