Force HTTPS using .htaccess file

Estimated read time 1 min read

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]

You May Also Like

More From Author