Force http to https redirection using .htaccess

There are lots of things you can do using the .htaccess file with Apache. One of the most frequently used directive by me is the RewriteRule for redirecting all http requests to https. The easiest way to force redirect any request received on http to https and maintaining the URI request is added below


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