I need to protect my whole website (It's just for development at the moment) with a password. So I created a .htaccess
and a .htpassword
file. The .htaccess
contains
AuthUserFile /my/absolute/path/.htpassword
AuthName "Protected"
AuthType Basic
Require valid-user
My directory tree looks like this
/var/www
|--- file.php
|--- .htaccess
|--- dir
| |--- text.html
|--- file2.php
If I try to access file.php
or file2.php
(any file which is directly in /var/www
), the webpage is protected by the password. However, I can access the file in the subdirectory (/dir/text.html
) without any authentication. I'm absolutely certain that there's no .htaccess
in /var/www/dir
(I use ls -A
).
I've seen on the web that .htaccess
is supposed to have an effect on the directory and ALL subfolders, and that's what I want.
Do you know why it doesn't have any effect on the file in subdirectory in my case? If so, how can I make it work?
.htaccess
file in the document root should affect the entire directory tree, unless you have other.htaccess
files in subdirectories (or<Directory>
containers in the server config) that override this. However, if you've previously accessed/dir/text.html
before you implemented the authentication then it's possible you are seeing a cached response. (?) Make sure all local caches are cleared (try a different browser). Is there a proxy server on the network?/var/www/text.html
? Does it require authentication?