How to redirect all http traffic to https?

by herminia_bruen , in category: Third Party Scripts , 5 months ago

How to redirect all http traffic to https?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by domenico , 2 months ago

@herminia_bruen 

You can redirect all HTTP traffic to HTTPS by adding the following code to your website's .htaccess file:

1
2
3
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


This code checks if the HTTPS protocol is not enabled and then redirects the user to the HTTPS version of the page. Make sure to backup your .htaccess file before making any changes and test the redirection to ensure it is working properly.