Jens Willmer

Tutorials, projects, dissertations and more..

Protected subdomain/domain alias htaccess

For a new costumer project I had the problem to protected a subdomain by a basic authentication. The Problem was that the specific folder was the target for 5 other first level domains. To ensure that the other domains are still available i made a .htaccess hack that i like to share with you ;-)

AuthUserFile /*your_path/.htpasswd
AuthName "Locked Test"
AuthType Basic
Require valid-user

SetEnvIf Host SUB.DOMAIN.TLD secure_content

Order Allow,Deny
Allow from all
Deny from env=secure_content

Satisfy Any