How to Re-direct http to https

After you installed an SSL certificate for your domain, you may want to re-direct your visitors from http:// to https://. This will help your webpage load securely. Now, google search ranking also supports https://, this will also help your SEO.

You can modify your .htaccess file and add the following code to the beginning of your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Your .htaccess file needs to be in the root folder of your website to make it works.

Re-direct non-www to www domain

For consistency and SEO purposes, this will prevent Google from indexing both www and non-www domain version of your site and avoid duplicated content issue. I prefer to re-direct from non-www to www, so here is my code that I’m using on clipsify.com. Just copy and past into your .htaccess file and it will work right away.

# Redirect from non-www to www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# End Redirect from non-www to www
Page 1 of 1