How to force visitors to use HTTPS

How to make visitors use HTTPS when they use the domain “domain.org” or “www.domain.org”? If they don’t add “https://” in the beginning, they will use HTTP.

Error Message

no error

Other Information

none

Make a file in htdocs called .htaccess, and put this in there.

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you use CloudFlare, there is a setting for that in SSL/TLS.

6 Likes

It worked, THANKS!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.