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:

Compromised Wordpress Cleanup and Recovery

Disclaimer: This is a simplified guide for recovering from a compromised wordpress installation....

How to Check for a Firewall Block

Our cPanel servers come pre-installed with ConfigServer Security & Firewall or 'CSF', which...

Getting Started

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

Why are my emails being marked as spam?

If you are receiving bounceback messages or tags that your messages are being marked as spam and...

How can I reinstall my server?

***THESE STEPS WILL RE-IMAGE YOUR MACHINE AND YOU WILL LOSE PREVIOUSLY STORED DATA. PLEASE USE...