This article explains how to redirect from HTTP to HTTPS by creating or editing an .htaccess file.
SSL certificates
Before redirecting to HTTPS, make sure you have an SSL certificate on your domain.
You can check this by visiting your website with https: // at the beginning of the URL. For example, for planethoster.com, type https://planethoster.com to check.
In case of error, you will have an error of the type “Your connection is not private”.
In the majority of cases, you will not get an error message because PlanetHoster installs free SSL certificates on all accommodations.
HTTP to HTTPS Redirection
Following the installation of the SSL / TLS certificate, the traffic is not necessarily redirected to HTTPS.
If you use a CMS (for example, WordPress, PrestaShop or Joomla !), you can create this redirection by following the tutorials below:
- WordPress: How to set WordPress in HTTPS?
- PrestaShop: How to set PrestaShop in HTTPS?
- Joomla: How to set Joomla in HTTPS?
Following the configuration of your CMS or for homemade sites, you need to edit or create a .htaccess file at the root of your site.
For simple traffic redirection, add the following code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
This code allows you to redirect while specifying the domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^YourDomain\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
Your Website Does Not Have a Green Lock?
When your site is in HTTPS, on some occasions it may happen that some of your web pages remain with items that are not secure. Result: the site in question does not show the green padlock, which is the appropriate sign stating that a site is completely secure in HTTPS.
To remedy this, we invite you to visit the following link to determine the elements causing this problem: https://ssl-lookup.io/. By entering your website link, the tool automatically lists all unsecured items on your site. It is then be necessary to examine the results and make the change on your site in order to solve the situation.