It is necessary to ensure that visitors to your website use the SSL encrypted connection.
NOTE: If you are not familiar with SSL certificates and want to know more, visit our article When and why to use an SSL certificate?
If you need assistance on this topic, do not hesitate to contact us, you can contact us in our live chat or via whatsapp.
To force all web traffic when using HTTPS, insert the following lines into the code of the .htaccess file in the root folder of your website.
- Login to CPanel
- Enter the file manager.
3. Find the directory from which we want to modify the .htaccess file.
Now to open the editor, right click
4. Here you must add the lines of code at the end.
Code
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.dominio.com/$1 [R,L]
Important: If you have existing code in your .htaccess, add it below where there are already rules with similar prefixes:
Be sure to replace www.example.com with your domain name.
To force a specific domain when using HTTPS, insert the following lines into the code of the .htaccess file in the root folder of your website:
Code to force a specific domain when using HTTPS
RewriteEngine On
RewriteCond %{HTTP_HOST} ^dominio\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.dominio.com/$1 [R,L]
Be sure to replace www.example.com with the domain name you're trying to force HTTPS on. Additionally, you need to replace www.example.com with the domain name.
If you want to force your SSL on a specific folder, you can enter the code below inside the .htaccess file, put in that specific folder.
Code To force your SSL on a specific folder
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.dominio.com/carpeta/$1 [R,L]
Make sure you have renamed the folder to the actual name of the folder. Next, make sure to change www.domain.com/folder to the domain name and folder you want to force SSL with.