So I have multiple (sub)-domains. All of them link towards one server, but on different folders with different file structures. For example:
http://webapp1.example.com/ //Subdomains don't have https (no wildcard)
https://www.example.com/webapp_that_needs_https (some webapps are required to have https and therefore can't be on a subdomain)
http://webapp2.example.com/
Every webapp has its own .htpasswd-protection, this is the .htaccess-file:
# Password
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /www/serverid/webpages/webapp1/.htpasswd
Require valid-user
Now I want to make a webpage on a subdomain, that lists and links all of the webapps. This file should be password-protected as well. If the user navigates to one of the webapp-pages using this password-protected list, the htaccess-protection for the webapps should be skipped.
If the user skips the listing page and navigates directly to the webapp-domain, the password protection should appear as usual.
Is there any way to achieve this probably really uncommon feature?
I believe you can do this using an if directive
. In your .htaccess
you would use:
<if "%{HTTP_HOST} != 'example.com'">
....
</if>
So you would put the domain you want them to refer from in the if directive
and if it does not match, then it runs the Auth Type
. Leaving your final code with:
<if "%{HTTP_HOST} != 'example.com'">
# Password
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /www/serverid/webpages/webapp1/.htpasswd
Require valid-user
</if>