Forcing secure HTTPS navigation using .htaccess

Forcing secure HTTPS navigation using .htaccess


Once the SSL Certificate is installed, it is ideal for visitors who access your website to be immediately redirected to the HTTPS version of it, so they can browse securely. This redirection is not configured automatically when the certificate is installed, and it requires a few small changes in your hosting.
 
If you have a CMS installed on your hosting, there are plugins that allow you to make this change automatically.
 
In this guide we will show how to force secure HTTPS navigation using the .htaccess file
 
First of all, you need to access your hosting via FTP in order to activate it:
 
To connect to the "webFTP" service, you need a username and password which you can find in your cdmon control panel, in the hosting management section, under Hosting information. By clicking the eye icon you can view the password, which is hidden for security reasons.


Once you have the connection details, you must access the FTP manager from the hosting management panel itself by clicking the icon Web FTP access (net2ftp), in the 'File managers' section.
 

In the webFTP manager login panel you must enter the FTP details (username and password) found in the 'Hosting information' section.


After accessing webFTP you will be able to view the files and/or directories of your hosting. You must enter the folder /web:
 

Once inside the /web folder, all the files of your site will appear. You must locate the file named .htaccess and click Edit on that file.
 
The code of the .htaccess file will automatically open. You only need to add the following lines at the end of the file:
 
RewriteEngine On
RewriteCond %{HTTP_HOST} yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]
 
IMPORTANT: You must replace the domain in the previous lines with the domain name of your hosting.
 
 
For more information, you can contact us.
    • Related Articles

    • How to protect folders using a .htaccess

      Through the file .htaccess you can protect any directory in your hosting account. 1.- How to create and where to place a .htaccess and .htpasswd file To create a .htaccess or .htpasswd file, open Notepad and enter the required code. Save the file as ...
    • .htaccess default from PrestaShop

      The .htaccess file is a configuration file used on Apache-based web servers. It is used to control and configure the behavior of a website. The .htaccess file has multiple functions and allows you to customize a website’s configuration in a specific ...
    • .htaccess default from WordPress

      The .htaccess file defines the configuration and behavior of the folder where the .htaccess file is located. In other words, it allows you to manually configure friendly URLs or define the access path for that WordPress installation. The code shown ...
    • Information and uses of the .htaccess file

      1.- What is a .htaccess? The .htaccess (hypertext access) file is the default name for Apache’s directory-level configuration file. It is used to customize the configuration of directives and parameters defined in the main hosting configuration file. ...
    • How to connect via FTP using WinSCP

      To upload your website to your cdmon hosting account, you need an FTP client. An FTP client is special software that connects to the web server using the FTP communication protocol and allows you to manage your website as if it were Windows Explorer. ...