I have added a RewriteRule to force https on one domain at the end of my .htaccess file

RewriteCond %{HTTP_HOST} ^www.mydomain\.be [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

It is working fine except that after that, I get a /index.php/ inside all URL

If I add RewriteEngine on before like the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mysite\.be [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Then my /index.php/ problem is solved...

I am happy with that, but I don't understand why

Note: Those lines are added at the end of a regular drupal .htaccess. I mean no change in it except that I have uncommented the all to "www" rule (before my https rule at the end)

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

There are no special apache2 conf as welll

1 Answer 1


I suggest you look at the .htaccess file supplied with Drupal, beside index.php. In the standard one, it has rules for both redirecting http: to https: (line ~104) and for rewriting URIs to index.php (line ~136)

Some servers are configured with these rules in the main config file because relying on .htaccess results in slower response from Apache (it reads the main files on startup but .htaccess per request).

So: - Remove any additional rules you have added (i.e. revert to "out of the box") and check for expected behaviour; - Uncomment the protossl conditions in .htaccess and check again; - Optionally, move some of these into the .conf file for faster response.

  • Even if I haven't get the real explaination for my (none) problem, I accept this answer because I understood that I could remove all .htaccess (AllowOverride None) in my 3 multisite install (drupal7/drupal8/drupal8.7 with many sites in each). I have made one drupal.conf file (for all 3 multisite) with the RewriteRule to force https at the end and averything is running fine. Thank you .
    – Baud
    Jun 10, 2019 at 8:45
  • Glad it helped.
    – rivimey
    Jun 10, 2019 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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