Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Basic Auth Exclude Single File

Tags:

Part of my .htaccess file looks like this-

AuthUserFile /path/to/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user

Doing that requires the Basic HTTP authentication for the entire directory and the directories below it as well. However, I have a single file within that root directory, thubservice.php, that should not require the HTTP authentication.

From what I have seen, I need to use <FilesMatch />, but I cannot figure out the pattern to match all but that given file.

like image 938
Brandon Hansen Avatar asked Oct 05 '10 15:10

Brandon Hansen


2 Answers

AuthUserFile /path/to/.htpasswd AuthName "Authorization Required" AuthType Basic require valid-user <Files "thubservice.php">     Satisfy Any     Allow from all </Files> 
like image 155
talyric Avatar answered Oct 03 '22 23:10

talyric


With Apache 2.4 you may want to use Require instead:

<Files "thubservice.php">     Require all granted </Files> 

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module mod_access_compat is provided.

like image 26
wrwrwr Avatar answered Oct 03 '22 23:10

wrwrwr