Reputation: 7555
I have Drupal Site.
I have checked all the below links, but either they don't redirect or I gets an error- Site has too many redirects
I need to redirect my complete site HTTP to HTTPS except for two pages:-
The below code-snippet redirects complete site to HTTPS with no issue but I need to escape the Home & products page & for that I have tried about with more than 10-15 combinations.
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hello\.com*
RewriteRule ^(.*)$ https://hello.com/$1 [L,R=301]
Any Help Highly appreciated.
Upvotes: 2
Views: 286
Reputation: 4302
Ok let's try with you , this is your code :
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hello\.com*
RewriteRule ^(.*)$ https://hello.com/$1 [L,R=301]
change it to this :
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.hello\.com*
RewriteCond %{SCRIPT_FILENAME} !products [NC]
RewriteRule ^(.+)$ https://hello.com/$1 [L,R=301]
Please try it and let me know if not doing what you want.
Upvotes: 0
Reputation: 18671
You can use:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.hello\.com
RewriteCond %{REQUEST_URI} !^/products/?$ [NC]
RewriteRule ^(.+)$ https://hello.com/$1 [L,R=301]
Upvotes: 2