Mod_rewrite with exceptions

To redirect every request on my server to a secure connection, I use

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

which works great.

However, I need the two paths not to be redirected.

Speak when I access

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

I want to go this way. Is this possible with mod_rewrite?

+4
source share
1 answer

Try something like this:

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

All Articles