How to redirect all traffic via .htaccess to https?

Member

by addison , in category: Third Party Scripts , 4 months ago

How to redirect all traffic via .htaccess to https?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by lindsey.homenick , 4 months ago

@addison 

To redirect all traffic to HTTPS using .htaccess, you can add the following code to your .htaccess file:

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


This code checks if the current request is not using HTTPS and then redirects it to the same URL with HTTPS. Make sure to test the redirection after adding this code to your .htaccess file to ensure that all traffic is properly redirected to HTTPS.