How to set https-only header on .htaccess?

Member

by lily , in category: Third Party Scripts , 3 months ago

How to set https-only header on .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by domenico , 3 months ago

@lily 

To set up an HTTPS-only header on your .htaccess file, you can add the following code:

1
2
3
4
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


This code will check if the HTTPS protocol is off and then redirect all traffic to the HTTPS version of the website. Make sure to save the changes to your .htaccess file and test it to ensure that it is functioning correctly.