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>

  • https, ssl, re-direct, redirect, ssl redirect, http to https
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How many domains can I host on my virtual machine?

You can host as many domains as you'd like as this is not limited however, you must make sure...

Getting Started

To first access your VPS, you may most easily connect via the VNC client in the DotBlock control...

How can I change my OS?

This tutorial will show you how to change the operating system on your VPS ***THESE STEPS WILL...

How many IP addresses are provided with my VPS?

One IP address is provided with the establishment of your VPS account. Should you need to add...

What is ACPI?

ACPI stands for Advanced Configuration and Power Interface.  It provides an open standard for...