|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Is it possible to protect a file and also a sub directory using different password files? As I am now, everytime I enter a password to access the file, or the directory, I can access both the file and the directory.
This is not what I am interested in doing. I want one or the other, otherwise 2 passwords have to be entered to get both. Is this possible? Thanks, Tim |
|
#2
|
|||
|
|||
|
Yes. If you have access to httpd.conf, use <LocationMatch>. If not, use <FilesMatch> in your .htaccess file.
<FilesMatch "somefile.html$"> AuthName "Dimman Site" AuthType Basic AuthUserFile /path/to/.htpasswd require valid-user </FilesMatch> <FilesMatch "anotherfile.html$"> AuthName "Dimman Site" AuthType Basic AuthUserFile /path/to/another/.htpasswd require valid-user </FilesMatch> The known bug of using FilesMatch for your purpose is that, if the same file is found under the subdirs of your .htaccess, it will also match and prompt for login. Using <LocationMatch>, however, give you exact URL match. <LocationMatch "^/private/anotherfile.html$"> |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > .htaccess files to protect a file and a sub directory using different "realms"... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|