1. Home
  2. SSL/TLS
  3. How do I redirect my site from http (without SSL) to https (with SSL)?

How do I redirect my site from http (without SSL) to https (with SSL)?

Den här artikeln finns även på svSvenska

To redirect all links on a website from HTTP to HTTPS you can add the following code to the top of the .htaccess file for the site:

<IfVersion < 2.4>
RewriteCond %{HTTPS} off
</IfVersion>
<IfVersion >= 2.4>
RewriteCond %{REQUEST_SCHEME} ^http$
</IfVersion>
RewriteCond %{REQUEST_URI} !^\/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

For the redirect to work you need to put this code into the very top of the file exactly as it is written above. No editing of this code is needed.

You can use the File Manager in cPanel to edit your .htaccess file (or to create one if it does not exist). Keep in mind that you need to activate viewing of hidden files to be able to see the .htaccess file.

Was this article helpful?

Related Articles