htpasswd protection prompts for index.php download

ppnx nginx-forum at
Thu Mar 18 03:01:29 MSK 2010

I could not find the information on the web or in the wiki, so I try this list. I am the user of a free hosting service using nginx. So I cannot acces or edit conf files myself, but I can ask the admin and he will do it for me.

Basically, I want to protect whole folders. I think that I have managed to do that by asking the admin to add these lines to the nginx.conf file:

# Password Protect important Directories
location ~ /srv/www/users/me/(folder1|folder2)/.* {
auth_basic "Restricted";
auth_basic_user_file /srv/www/users/me/folder1/.htpasswd;

This does protect all files in folder1 and folder2. However, after entering the password, instead of seeing the index.php file display the page on screen, my browser pops up this download dialogue:

How can I avoid this behavior?

Posted at Nginx Forum:,65055,65055#msg-65055

More information about the nginx mailing list