Permanent redirect from http to https in .htaccess

apache logo

The following redirect rules can be used in the .htaccess for permanently redirecting http to https (secure connection) in Apache with SSL.

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

or

RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R]

Share on Facebook3Share on Google+0Tweet about this on TwitterShare on StumbleUpon0Share on LinkedIn0Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan

Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *