0
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com*
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

With this I swap from http:// to https://www in one single redirect step.

Unfortunately this does not work for sub-pages. So http://example.com/categorypage will get redirected to https://example.com.

How do I fix it? What should be added in .htaccess to fix the redirection from http to https for sub-pages?

1
  • I'm voting to close this question as off-topic because it is about server configuration that isn't influenced by Drupal.
    – apaderno
    Apr 17, 2018 at 9:24

1 Answer 1

1

Adding these lines to the default .htaceess file worked for me

# Force HTTPS across the Drupal site
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>

Also enable clean URLs for that site

1
  • I tried the above code but it still does not help fix the issue
    – harshal
    Apr 10, 2018 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.