I'm not entirely sure this is possible, but I have an application that is hosted on a few different URLs and a few different subdomains.
Each of these has a basic protected section (using htpasswd).
I'd love to be able to have ONE htaccess file, rather than having a bunch of different ones that point to different files.
I have the following file structure:
.htaccess .htpasswd-domainone .htpasswd-domaintwo .htpasswd-domainthree
Is there a way to do something like this?
<If "%{HTTP_HOST} == 'domainone'">
AuthUserFile /file/location/.htpasswd-domainone
</If>
<If "%{HTTP_HOST} == 'domaintwo'">
AuthUserFile /file/location/.htpasswd-domaintwo
</If>
<If "%{HTTP_HOST} == 'domainthree'">
AuthUserFile /file/location/.htpasswd-domainthree
</If>
Taking subdomains into account?
Assuming Apache 2.4, the following works: