How to Force SSL Redirect HTTP to HTTPS

October 25, 2023 / SSL

This guide explains how to force SSL to redirect HTTP to HTTPS. Enabling SSL applications is crucial for ensuring security protocols. It is advisable to activate this feature if you have a valid SSL Certificate installed.

Follow the instructions below based on your web hosting plan, whether it is Linux or Windows:

Note- In the case of using WordPress, remember to update your HOME / BASE URL when executing these modifications.

  1. For Linux accounts- Enabling HTTPS (Linux hosting)
    HTTPS Redirects automatically convert insecure requests (http://) to secure requests (https://).
    Follow the below steps to enable HTTPS for your site:

    1. Direct to the ~/public_html directory.
    2. Access the .htaccess file or generate a new one.
    3. Copy the following code and insert it into the .htaccess file.
    4. Save your alterations to the .htaccess file. Your site now supports HTTPS.
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  2. For Windows accounts- Forcing HTTPS (Windows hosting)
    To implement SSL for your site using web.config, adhere to these guidelines-

    1. Steer to the “wwwroot” directory.
    2. Open the “web.config” file.
    3. Paste the following lines into the web.config file. Integrate these rewrite rules to enable HTTPS on the Web.Config for any domain.
      <system.webServer>
      <rewrite>
      <rules>
      <rule name=”Redirect HTTP to HTTPS” stopProcessing=”true”>
      <match url=”(.*)” />
      <conditions>
      <add input=”{HTTPS}” pattern=”off” />
      </conditions>
      <action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}”                                                redirectType=”Permanent” />
      </rule>
      </rules>
      </rewrite>
      </system.webServer>

That is it! If you continue to encounter difficulties, please reach out to us for additional assistance.

Spread the love