Security, PKI, sys and network admins

How to force browser redirect insecure HTTP to secure HTTPS, on your website

This article’s purpose is to show you how to force the web browser redirect your insecure HTTP web site to secure HTTPS by using .htaccess.

  1. Generate your own free OpenSSL certificate for your website.
  2. Create a file called .htaccess and PASTE the following code into it (NOTE: the file must be created inside the root of your website; for example, inside the www/ or public_html/ folder of your website):
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  3. Test your work by typing inside a private window of your web browser, your domain but without the http or www. For example, type just yourdomain.com and check your browser’s return:
How to force browser redirect insecure HTTP to secure HTTPS, on your website
busy.network example