If your site is already available via the HTTPS protocol you would want to have your customers come to the secure version of the site instead of HTTP connection.
You can set up a redirect to https/non-www or https/www version of your site (you can only choose one, which you consider canonical).
In order to do this, the .htaccess file should be edited.
As a reminder, the template structure looks like this:
/mt-admin/
/mt-content/
/mt-includes/
.htaccess
api.php
app.php
common.php
index.php
In case you don't see the .htaccess file, your FTP and your File Manager tool of your hosting are not showing the files with dot names. You'd need to select show hidden files first:
In FileZilla, go to Server > Force showing hidden files
In the File Manager of your hosting click Settings in the upper right corner
Select your Document Root and check the box for Show hidden files and click Save
Redirecting the website to https/non-www
Once the .htaccess file is open, you should put the following below the RewriteEngine On command:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) https://example.com/$1 [L,R=301]
Where example.com should be replaced with your domain name
Redirecting the website to https/www
Once the .htaccess file is open, you should put the following below the RewriteEngine On command:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The redirect is successful if you're not able to type any variation of the domain name besides the one you intended - https/non-www or https/www
Comments