If you want to ensure that visitors always access your website over a secure HTTPS connection, you can enforce it using the .htaccess file.
Add the Following Code to Your .htaccess File:
Where to Place the Code
-
This code should be placed at the top of your site's
.htaccessfile. -
The
.htaccessfile is typically located in the root directory of your domain (e.g.,/public_html/).
What This Does
-
It checks if HTTPS is off.
-
If it is, it redirects all requests to the HTTPS version of the current URL using a 301 permanent redirect.
This helps secure all traffic to your site and is also beneficial for SEO and user trust.
