1000 FAQs, 500 tutorials and explanatory 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 (SSL) version of a site on Infomaniak Web Hosting.
This redirection is usually automatic with standard configuration and installation ⚠️ For additional help contact a partner or submit a request for proposal — also read the role of the hosting provider
Prerequisites
- Have a valid and functional SSL certificate for the Infomaniak website
Manual Redirection via .htaccess File
Simply modify or add the following 3 lines to the .htaccess file of the relevant website to ensure that all visitors are automatically directed to its secure HTTPS version:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain.xyz/$1 [R=301,L]
If Problems Arise
- Replace the second line of the code above with
RewriteCond %{HTTP:X-Forwarded-Proto} !https
With a CMS
Most web applications like WordPress and Joomla have extensions/plugins that automatically redirect site visitors to its secure HTTPS version.
WordPress
If you are using a content management system (CMS) like WordPress to build your site, we recommend installing an extension to handle this redirection:
- Back up the site's files and database as a precaution
- Install the Really Simple SSL extension or similar from the WordPress console and activate it
- Visitors will now be automatically redirected to the HTTPS version of the site
- If issues persist (after clearing cache, etc.), you may also use Velvet Blues Update URLs
Joomla
Find the line
var $live_site ='';
in the Joomla configuration file (configuration.php) on the server
Replace with
var $live_site = 'https://www.domain.xyz';
Add three lines to your .htaccess file on the server:
RewriteEngine On RewriteCond %{HTTPS} OFF RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
- Open the Joomla administration panel in "System - Configuration"
- Click on the "Server" tab and under "Force SSL" select "Administration and site"
- Save and visitors will now be automatically redirected to the HTTPS version of the site
Prestashop
- Go to the general settings in the Prestashop back-office to enable SSL:
- < v1.7 click on "Preferences" then "General"
- > v1.7 click on "Shop Parameters" then "General"
- Toggle the "Enable SSL" button to "YES"
- Click on "Save"
- In the same place, toggle the "Enable SSL on all pages" button to "YES"
- Click on "Save"
If a security lock does not appear in the browser or a warning is displayed, check the template or modules as sometimes they may not be fully compatible with SSL. Your Prestashop might be loading elements (images, .css or .js files, fonts...) over "http" when they should now be loaded over "https".
Drupal
This article (in English) explains how to switch a Drupal site 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 (.*) https://domain.xyz/$1 [R=301,L]
In the case of a redirection loop, adjust the code above to:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteRule (.*) https://domain.xyz/$1 [R=301,L]
In your .htaccess file, to force redirection with www
with subdomains:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule (.*) https://www.domain.xyz/$1 [R=301,L]
In the case of a redirection loop, adjust the code above to:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule (.*) https://www.domain.xyz/$1 [R=301,L]
and without subdomains:
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^domain.xyz [NC]
RewriteRule (.*) https://www.domain.xyz/$1 [R=301,L]
In the case of a redirection loop, adjust the code above to:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^domain.xyz [NC]
RewriteRule (.*) https://www.domain.xyz/$1 [R=301,L]
Common Errors with HTTPS Redirection
To resolve common issues that may arise from redirecting your website to its secure HTTPS version, consult this guide (click here).