Force SSL in Apache

This is nothing Earth shattering but it seems that this has come up quite a bit lately and I wanted a place to keep the information handy. So here it is:

If you want to force the use of SSL for a specific site, place this configuration in the .htaccess file in the document root.

<IfModule !mod_rewrite.c>
	LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{SERVER_PORT} !^443$
	RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</IfModule>

Care to recommend an alternate solution?


Tags:

 
 
 
blog comments powered by Disqus