How to redirect traffic from HTTP to HTTPS?

  1. Home
  2. Knowledge Base
  3. Hosting
  4. cPanel
  5. Web Hosting
  6. How to redirect traffic from HTTP to HTTPS?

After you have purchased an SSL certificate, you need to perform important changes on your website. Please follow these steps.

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