I have files with the same name in different directories on the serves (example: stats.php), and I want to password protect some of them (.htaccess file in the root directory). I tried "FilesMatch" with a path to the file and it didn't work, and I tried adding "Directory" path as follows, same problem.
<Directory /var/www/vhosts/folder/httpdocs/directory/> <FilesMatch "stats.php"> AuthName "Private file" AuthType Basic AuthUserFile /var/www/whatever/.htpasswd require valid-user </FilesMatch> </Directory>