Sun

How to redirect traffic from HTTP to HTTPS?

In order to redirect all request to your website through encrypted connection you have to edit/create “.htaccess” file in your “public_html” folder and paste this code:

RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

In order to redirect only specific part of the website use this code:

RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule secure.html https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Where “secure.html” is a part of your website which will be displayed through HTTPS protocol. If you would like to add more files use “|” operator, for example “secure.html|secure2.html|secure.php”

Was this article helpful?

Related Articles