php.htaccessacquia

Redirect to HTTPS doesn't include Request URI


In my .htaccess file I have added this general rule to redirect all non-secure requests to HTTPS. Works well until you type in a uri then it just directs you to the index page (with SSL).

Example: mysite.com is directed to https://www.mysite1.com works well, but mysite1.com/mypage is directed to https://www.mysite1.com the Request_uri is not included.

Here's the code I used:

  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This is a Drupal 8 site running on Acquia's Cloud.

Anyone have any clue what I did wrong?


Solution

  • So i figured out what i did wrong. There was nothing wrong with the rules i wrote but where in the .htaccess file i put them.

    I initially put them at the end of <IfModule mod_rewrite.c> section, after placing them just after the Authorization HTTP header inside the section it's working as expected