Rewrite rule – Force HTTPS / Linux

Forcing HTTPS is very easy to do in Apache.

The common command is to force everything to HTTPS. In your host file, under :80 make sure you have the following. At the same time, make sure you have :443 open and that your configuration is ready to host the new traffic.

#Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

To check if your apache config is working properly, you can run: apachectl configtest

Leave a Reply

Your email address will not be published. Required fields are marked *

*