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 behavior 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?
Require valid-user
from my .htaccess, then I see the files from /path/to/subdomain/files and if I uncommentRequire valid-user
then I see the main domain files (a Drupal CMS). How can requiring a valid user cause apache to deliver files from completely different directories?alias /mydir /path/to/subdomain/files/
try making italias /mydir/ /path/to/subdomain/files/
with a trailing slash after the alias.Require valid-user
set I see one directory (the wrong directory) and if I comment it out I see the right directory. In either case there is no user/password prompt and nothing in the apache error log.