Kgn-web
Kgn-web

Reputation: 7555

how to redirect complete site from HTTP To HTTPS except for 2 pages in Drupal Site?

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

Answers (2)

Mohammed Elhag
Mohammed Elhag

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

Croises
Croises

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

Related Questions