Password protect an alias virtual difrecory
- by Jason
I have a main domain being hosted through CPanel. I also have a sub-domain that I would like to appear as a path under the main domain instead of as a sub-domain. So I have:
http://example.com/ pointing to the main hosted file.
http://example.com/mydir pointing to the subdomain files.
This is achieved by a httpd.conf include from the main domain section to set an alias:
alias /mydir /path/to/subdomain/files/
Now, that works fine so far.
The problem is that if a .htaccess file under /path/to/the/subdomain/files/ contains an error, the alias is completely skipped, and /mydir goes instead to the main host files. That is kind of surprising to me - I would expect an error to return an error instead.
Now the killer: if I try to password protect /path/to/subdomain/files/, then trying to access http://example.com/mydir will again attempt to deliver from under the main hosted files and not from /path/to/subdomain/files/
I am not seeing any errors reported on the .htaccess file in the apache error log, so I am assuming the .htaccess is valid:
AuthUserFile /path/to/valid/readable/.htpasswd
AuthName "Secure Access"
AuthType Basic
Require valid-user
This kind of behaviour does not seem right to me. Is there something obvious that could be causing it? Or is this just the way it works? Perhaps using an alias is the wrong way to go?