Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Force HTTPS (SSL) for the URL displayed by the web browser
This guide explains how to redirect all visitors to a secure https version (SSL) of a website on Infomaniak's Web Hosting.
Introduction
- This redirection is generally automatic with a standard configuration and installation.
Manual redirection via the .htaccess file
Prerequisites
- You must have a valid and functional SSL certificate for the Infomaniak website.
Next, modify or add the following three lines to the .htaccess file of the website in question so that all its visitors automatically access its secure https version:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) {{URL_1}} [R=301,L]Replace domain.xyz with your domain name and the appropriate extension (.com, .fr, .ch, etc.).
If you encounter any issues, replace the second line of the code above with RewriteCond %{HTTP:X-Forwarded-Proto} !https.
With a CMS
Most web applications, such as WordPress and Joomla, have extensions/plugins that automatically redirect visitors to a site's secure https version.
WordPress
If you are using a content management system (CMS) such as WordPress to create your website, it is recommended to install an extension to perform this redirection:
- Back up the website's files and database as a precaution.
- Install the Really Simple SSL extension or a similar one from the WordPress console and activate it.
- Visitors are now automatically redirected to the https version of the site.
Joomla
Replace domain.xyz with your domain name and the appropriate extension (.com, .fr, .ch, etc.).
Find the line
var $live_site ='';in the Joomla configuration file (
configuration.php) on the server.Replace it with
var $live_site = '{{URL_3}}';Add three lines to your
.htaccessfile on the server:RewriteEngine On RewriteCond %{HTTPS} OFF RewriteRule (.*) {{URL_4}}- Open the Joomla administration panel under "System - Configuration".
- Click on the "Server" tab and, under "Force SSL", choose "Administration and site".
- Save, and visitors will now be automatically redirected to the https version of the site.
Prestashop
- Access the general settings in the Prestashop back-office to enable SSL:
- < v1.7 click on "Preferences" then on "General"
- > v1.7 click on "Shop Parameters" then on "General"
- Set the "Enable SSL" toggle switch to "YES".
- Click "Save".
- On the same page, set the "Enable SSL for the entire site" toggle switch to "YES".
- Click on "Save".
If a security padlock does not appear in the browser or a warning is displayed, the issue may lie with the template or modules, as they are sometimes not fully compatible with SSL. Your Prestashop may then load elements (images, .css or .js files, fonts, etc.) using "http" instead of "https", as it should.
Drupal
Read this article (in English) which explains how to migrate a Drupal website from http to https.
Alternative solutions
Replace domain.xyz with your domain name and the appropriate extension (.com, .fr, .ch, etc.).
In your .htaccess file, to force the site URL to be https:// but without www:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteRule (.*) {{URL_6}} [R=301,L]In the case of a redirection loop, adapt the code above as follows:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteRule (.*) {{URL_7}} [R=301,L]In your .htaccess file, to force the redirection with www:
with subdomains:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule (.*) {{URL_8}} [R=301,L]In the case of a redirection loop, adapt the code above as follows:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule (.*) {{URL_9}} [R=301,L]and without the subdomains:
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^domain.xyz [NC]
RewriteRule (.*) {{URL_10}} [R=301,L]In the case of a redirection loop, adapt the code above as follows:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^domain.xyz [NC]
RewriteRule (.*) {{URL_11}} [R=301,L]
Common errors after an HTTPS redirect
To resolve common issues that may arise after redirecting your website to its secure HTTPS version, please refer to this other guide.
Link to this FAQ: https://faq.infomaniak.com/1961
Has this FAQ been helpful?