I have configured a virtual host in Apache for serving content over SSL/TLS. Since I also want to allow other sites on my domain to use regular http, I have two document roots, one at /home/www/html
and one at /home/www/html-ssl
. I force SSL on my site with the following directives in a file in /etc/httpd/conf.d
:
<Directory /home/www/html-ssl/foo>
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire ( %{HTTP_HOST} eq "mydomain.com" )
ErrorDocument 403 https://mydomain.com/foo
</Directory>
This redirects any requests for http://mydomain.com/foo/
to https://mydomain.com/foo/
. However, when I try to access http://mydomain.com/foo
without the trailing slash, Apache searches for foo
in /home/www/html
instead of in /home/www/html-ssl
, causing a 404. Is there a way to tell Apache that http://mydomain.com/foo
should really look for the directory foo
in /home/www/html-ssl
, and then redirect to the https site? I thought that since DirectorySlash is on, Apache would be able to figure out that foo
is a directory, at which point it would see my <Directory>
section above and work its magic.