Redirect HTTP to HTTPS rewrite rule

Redirect HTTP to HTTPS rewrite rule

As you know Google announced that they will consider SSL factor in their serach algorithm. That means, if you have SSL certificate for your website, it may get benefit in search ranking.

Today, we will discuss, how can we redirect all HTTP request to HTTPS. Before you follow this article, you will have to ensure that you have installed SSL certificate for your website and it is working properly. If you have still not purchased an SSL certificate, you can purchase it from third party provider like Namecheap etc.

Redirect HTTP to HTTPS

In this article, we will consider that you are using Apache web server and mod_rewrite is supported on your web server. You can use the following .htaccess rule to redirect all your HTTP traffic to HTTPS:

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

The above rule will redirect all your HTTP traffic ( to HTTPS (

It is essential that you use R=301 in the above rewrite rule. This will set 301 redirection for HTTP to HTTPS hence your old URLs will automatically updated by search engine.

Leave a Reply