Htpasswd domain-specific conditions

I use the dns wildcard system, which routes all subdomains through a single web application and sets the user ID based on the first part of the URL (X.domain.com, where X is the username).

Now I want to edit the htaccess file to enable conditional httpauth using htpasswd for specific domains. e.g. if url = password.domain.com enable httpauth.

I am sure this is possible, but has limited knowledge of htaccess.

+4
source share
1 answer

You can use SetEnvIf , here is a snippet from this post from Tom Schlick.

 #allows a single uri through the .htaccess password protection SetEnvIf Request_URI "/testing_uri$" test_uri #allows everything if its on a certain host SetEnvIf HOST "^testing.yoursite.com" testing_url SetEnvIf HOST "^yoursite.com" live_url Order Deny,Allow AuthName "Restricted Area" AuthType Basic AuthUserFile /path/to/your/.htpasswd AuthGroupFile / Require valid-user #Allow valid-user Deny from all Allow from env=test_uri Allow from env=testing_url Allow from env=live_url Satisfy any 
+6
source

Source: https://habr.com/ru/post/1303222/


All Articles