Support Center » Knowledgebase » Unix Tips » How to redirect non ssl to ssl (http to https)

How to redirect non ssl to ssl (http to https)

For Unix/Apache

For Unix based web sites running under Apache, you may want to allow only SSL connections to pass through and automatically redirect people to your SSL site. This is done by detecting if they are connected on the non SSL and redirecting them to https://

This can be done by adding a .htaccess file in your web root directory with the following directive inside. If there is already a .htaccess file, you can add the content in the existing file either at the beginning or at the end of the file.

<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{HTTPS} !on RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R] </IfModule>

For Windows / IIS 7 and above

Create a file called web.config and place it in your web site root directory.

<?xml version="1.0" encoding="UTF-8"?>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(.*)" />
              <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />

Whenever someone types, they will be redirected to

Article Details
Article ID: 93
Created On: 01 Nov 2004 06:00 AM
 Login [Lost Password] 
Remember Me:
Please note that the login and password to the support area is NOT the same as your hosting control panel login and password
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads | Control Panel User's Guide | Server Status