Force redirection of web site pages (http://) to the secure site (https://)

A way to redirect the user to secure connection (https://) can be accomplished with a .htaccess file containing these lines:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

The .htaccess file should be uploaded in the web site main folder.

In case you wish to force HTTPS for a particular folder you can use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} securefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

The .htaccess file should be uploaded in the folder where you need to force HTTPS.


Properties ID: 000220   Views: 1441   Updated: 6 years ago
Filed under: