Forcing access to a site in HTTPS

View our site in SSL even when the user enters the url with the insecure connection

After setting the HTTPS protocol on our hosting, and having uploaded the SSL Certificate we are ready to be able to present our website in a secure way.

It is not said, however, that the user uses it, as not all providers force navigation in https, or at least, forced navigation in https does not work on all providers.

In a nutshell, if a user enters our previous link from http: // in the browser’s url bar, our site will be displayed in an unsecured mode, most likely receiving the warning from Google Chrome, or from other browsers .

How can I solve the problem?

We modify the .htaccess in the root of our site by inserting the following lines

RewriteEngine On
RewriteBase
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

It is important to specify that if our hosting does not allow https navigation on third-level domains, we will have to insert the lines after the Rewrites of the subdomains.

We periodically check the functioning of the links in our articles. If you notice any links that do not work, please let us know in the comments. If you enjoyed the article consider supporting the blog with a small donation. Thank you. Patreon / Ko-fi / Liberapay / Paypal

Leave a Reply

Your email address will not be published. Required fields are marked *