Require a sub-directory of a website to only be accessible using a https / ssl connection

By | January 9, 2012

If for example you want to allow http access to your whole site but require https for /admin/ then use the following either in your httpd.conf or .htaccess file located in the root of the website.

RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} admin
RewriteRule ^(.*)$$1 [R,L]