How to force SSL (https) with .htaccess

Force the use of HTTPS and ensure a secured communication

The use of HTTPS can be forced to ensure all the data transferred between the website and the visitors is encrypted. 


  • Installed SSL Certificate

Completion of the task: 10 minutes

Expertise: intermediate

How to do it?

To force your entire website to go through https, you can add these rules to your .htaccess file. (You can access your .htaccess file with a FTP client or with the File Manager).

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]

If your site is in a subfolder, use this code: 

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$$1 [R,L]

NOTE: Replace with your domain name and the folder with subfolder in which your site is located and it will work!

Renouveler un certificat SSL


Please sign in to leave a comment.