How do I re-direct non-https traffic to the https version of the website?

To re-direct a single site from http:// to https:// or https://www you would add the following code to an .htaccess file in the document root for the website (make sure to edit the entry for your specific domain):

Option 1 Redirects all http:// requests to the same website page, but with https://

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule .* https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>

Option 2 Redirects all http:// requests to the same website page, but with https://www.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule .* https://www.example.com%{REQUEST_URI} [R=301,L]
</IfModule>

Was this answer helpful?

 Print this Article

Also Read:

How do I upload files to my Linux server?

First, make sure you have a working ftp client. We recommend FileZilla. Most Linux Distributions...

How do I change boot order, and change the CD/DVD image?

1. Log into your client area at http://cp.dotblock.com     2. Click “Manage Servers” at the...

Basic Linux Server Administration

Basics:Here are a few simple commands to be used from the SSH/VNC command line on most linux...

How do I VNC to my server?

1. First you will need to log in to your DotBlock client area,...

How do I add a DNS zone for my domain?

In order to use the DotBlock DNS management, you will want to point your domains' nameservers to...