How to Force Redirect Http to Https and non-www to www

In this article we show you how to easily force redirect your website from http to https and from non-www to www, in your cPanel without the need for technical knowledge – meaning anyone with cPanel access can do it.
We will assume that you already have an ssl installed on your server, and we will quickly show you how to check if you have AutoSSL installed and enabled in your cPanel.

We put a short video together for you showing you exactly how to achieve these redirects so that your website always resolves with https://www.yourdomain.ca, instead of having variations like:

  • yourdomain.ca
  • www.yourdomain.ca
  • http://yourdomain.ca
  • https://yourdomain.ca
  • https://www.yourdomain.ca

Having all these variations of your domain, without proper 301 redirects, can cause serious issues with your SEO, more specifically with your Google rankings because Google treats these variations of the same homepage as different pages, which can split your page rank (ranking power) and in effect negatively affect your rankings.

Please see the following video which explains exactly how to achieve 301 redirects from http to https and non-www to www considering you have SSL installed and enabled on your server.

 

 

 

Rewrite Engine On
RewriteCond% {HTTPS} off
RewriteRule ^ (. *) $ Https: //% {HTTP_HOST}% {REQUEST_URI} [L, R = 301]

If above code is not working for you then you can use the below code. Just make sure to replace yourdomain.ca with your actual domain name.

RewriteOptions inherit
AddType application/x-httpd-php .html .htm
#AddType application/x-httpd-php55 .php
##AddHandler application/x-httpd-php56 .php
AddType application/x-httpd-php .html

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.ca [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.yourdomain.ca/$1 [L,R=301]

RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)index.html$ https://www.yourdomain.ca/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.ca
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) http://www.yourdomain.ca/$1 [R=301,L]

Recent Posts

A Review of Booker Customer Relationship Management (CRM) Software for Medical Spas

Ratings: 4.1 Stars (Capterra) | 4.1 Stars (GetApp) Booker by Mindbody is a prominent CRM…

1 week ago

Top 3 Affiliate Software Picks for Easy Integration

Affiliate marketing software offers a smart and convenient solution for businesses to refine their marketing…

2 weeks ago

Accountability Chart 101: A Must-Have Tool for Medical Practice Management

For medical practices, where a single client’s experience relies on multiple team members working in…

2 weeks ago

Most Popular Screen Resolutions in the US

When creating and optimizing a website, one of the most important factors that some businesses…

1 month ago

How to Effectively Supercharge Healthcare Marketing with Patient Personas

One of the biggest challenges in creating an effective healthcare marketing strategy is recognizing that…

1 month ago

How To Take Better Photos For Clinics Specializing in Vaginal Rejuvenation

As more women become increasingly interested in vaginal rejuvenation, having appropriate and professional vaginal rejuvenation…

2 months ago