Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Force the browser's displayed URL to use httpS (SSL)
This guide explains how to redirect to a secure https version (SSL) all visitors to a site on Web Hosting Infomaniak.
Preamble
- This redirection is usually automatic with a standard configuration and installation.
- If necessary, local partners referenced by Infomaniak can handle these procedures: launch a free call for tenders; they take care of everything, freeing you from technical details — also discover the role of the host.
Manual redirection via .htaccess file
Prerequisites
- Have a valid and functional SSL certificate for the Infomaniak website.
Then, modify or add the following 3 lines to the .htaccess file of the website concerned so that all its visitors automatically access its secure https version:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain.xyz/$1 [R=301,L]Replace domain.xyz with your domain name with the appropriate extension (.com, .fr, .ch, etc.).
Replace the second line of the code above with RewriteCond %{HTTP:X-Forwarded-Proto} !https in case of a problem.
With a CMS
Most web applications like WordPress and Joomla have extensions/plugins that automatically redirect visitors to a site to its secure https version.
WordPress
If you are using a content management system (CMS) like WordPress to create your site, we recommend installing an extension to perform this redirection:
- Save the site's files and database as a precaution.
- Install the extension Really Simple SSL or similar 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 with the appropriate extension (.com, .fr, .ch, etc.).
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
.htaccessfile 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" 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 "Store settings" then on "General"
- Enable the "Enable SSL" toggle switch to "YES"
- Click on "Save"
- In the same place, enable the "Enable SSL on the entire site" toggle switch to "YES".
- Click on "Save".
In the event that a security padlock does not appear in the browser or a warning is displayed, check the template or modules as these may not be perfectly compatible with SSL. Your Prestashop then loads elements (images, .css or .js files, fonts...) in "http" while these should now be loaded in "https".
Drupal
Refer to this article (in English) which explains how to switch a Drupal site from http to https.
Alternative solutions
Replace domain.xyz with your domain name with 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, adapt 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, adapt 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, adapt 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 following an https redirection
To resolve common issues that may arise after redirecting your website to its secure https version, refer to this other guide.
Link to this FAQ:
Has this FAQ been helpful?