2

I have found following .htaccess code on stackoverflow.com to convert the http requests to https

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

it is converting the http to https but always goes to the home page

suppose If I am trying to go to http://domain.com/about-us it routes me to https://domain.com

Just for information I am using redirect and global redirect module but even if I am disabling them both the result is same.

3

By default, Drupal includes an .htaccess file that has instructions in the comments for doing https redirection. I suggest you follow the instructions in that file.

From Drupal 7.22:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Set "protossl" to "s" if we were accessed via https://.  This is used later
  # if you enable "www." stripping or enforcement, in order to ensure that
  # you don't bounce between http and https.
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]
  • what does this mean Set "protossl" to "s" if we were accessed via https://. This is used later – Fahad Apr 18 '13 at 7:35
  • 1
    @Fahad You need to read the whole comment... "This is used later if you enable "www." stripping or enforcement, in order to ensure that you don't bounce between http and https." – Clive Apr 18 '13 at 9:55
  • I dont think this actually does a rewrite ? this just sets a variable to remember we are https – commonpike Jul 13 '15 at 10:50
0

Somewhere halfway the htaccess file drupal rewrites every request to non-existing files to index.php for fancy urls. Be sure to put your rewrite before that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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