Click to See Complete Forum and Search --> : allowing access to a directory/file that is below a restricted directory
EyesWideOpen
10-17-2000, 05:30 PM
How do I allow access to a directory or file(i.e., no password protection) that is below a directory that is password protected? I know that I could put .htaccess files in every other directory besides the one I don't want protection on but this can get very tedious.
I'm thinking that there has to be a more efficient way...
------------------
"Ford," he said, "you're turning into a penguin. Stop it."
~ THGTTG
freebsd
10-18-2000, 08:02 AM
Check out the following directives:
1) <DirectoryMatch> - if you have write access to httpd.conf
2) <LocationMatch> - same as above
3) <FilesMatch> - can be placed in .htaccss and it also matches Directory, not just file.
i.e.
<LocationMatch "^/[protect|secret]/$">
AuthName "Private Only"
AuthType Basic
AuthUserFile /path/to/same/.htpasswd
require valid-user
</LocationMatch>
This protects /protect dir or /secret dir but not the recursive subdirs because of the $ sign. So basically you can place only the directories (no subdirs) you want to protect within the [] brackets.
[This message has been edited by freebsd (edited 18 October 2000).]
EyesWideOpen
10-18-2000, 10:45 AM
This is close...
What would the syntax be for specifying "any location that does not match" instead of listing all that do match?
In other words can I do this:
<LocationMatch !"^/[unprotected|nonsecret]/$">
AuthName "Private Only"
AuthType Basic
AuthUserFile /path/to/same/.htpasswd
require valid-user
</LocationMatch>
Notice the exclamation point(!). Is this legal sytnax?
freebsd
10-18-2000, 07:13 PM
Correction:
<LocationMatch "^/[protect|secret]/$">
Should be:
<LocationMatch "^/(protect|secret)/$"> or <LocationMatch ^/(protect|secret)/$>
>>Notice the exclamation point(!). Is this legal sytnax?
It's a legal syntax in regex but no in this situation. BTW, do you have more protected dirs than unprotected ones?
The "Order" directive has the same logic. i.e. Should you "allow,deny" or "deny,allow".