RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^/dir/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} ^/dir/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]