Archive

Posts Tagged ‘mod_rewrite’

Apache: Force SSL for a Directory Using .htaccess and mod_rewrite

December 12th, 2005 No comments

To force SSL on a given directory using .htaccess, use the following code. It requires mod_rewrite enabled in Apache. Adjust the path in the RewriteRule to match the full qualified URL of the HTTPS-domain.


RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]