This seems to be a common question but I am having the devil's own time getting it working.
I want to have a subdirectory of DocumentRoot being served by apache2 to force-redirect to https. The directory accesses OK when I manually type https://www.myserver.com/subdirectory, but I want to force any http://www.myserver.com/subdirectory requests to redirect to https instead.
I am putting commands inside of Directory directive inside a config file; putting SSLRequireSSL in httpd.conf just kicks me to 403 Forbidden error. I have tried blocks of code (with mod_rewrite enabled) like:
RewriteEngine On
RewriteCond %{SERVER_PORT} !443$
#or
#RewriteCond %{SERVER_PORT} ^80$
#or
#RewriteCond %{HTTPS} off
RewriteRule ^/securesubdir(.*) https://%{HTTP_HOST}%{REQUEST_URI}
and I've tried this inside of httpd.conf, inside of sites_enabled/000-default-ssl, even inside of sites_enabled/000-default
What other commands should I try (and in which of the myriad config files should they go)?
Bookmarks