Password protecting folder breaks PHP within that folder

I’m trying to password protect a folder using htpasswd, works fine and
asks for a l/p, however php in that particular folder refuses to work.
PHP works anywhere else but the password protected location. Once I
comment out the password protected location and restart nginx it’s fine
again. Wondering if someone can assist?

nginx.conf is here: http://raab.ftw.net.nz/nginx.conf

Posted at Nginx Forum:

Igor S. Wrote:

     index  index.php;
     auth_basic            "Restricted";
 location ~ \.php$ {

[email protected]
nginx Info Page

That works brilliantly, thanks for that :slight_smile:

Cheers,
James

Posted at Nginx Forum:

On Thu, Dec 03, 2009 at 01:35:28AM -0500, raab wrote:

I’m trying to password protect a folder using htpasswd, works fine and asks for a l/p, however php in that particular folder refuses to work. PHP works anywhere else but the password protected location. Once I comment out the password protected location and restart nginx it’s fine again. Wondering if someone can assist?

nginx.conf is here: http://raab.ftw.net.nz/nginx.conf

 root    /var/www;

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include /etc/nginx/fastcgi_params;

 location / {
     index  index.php;
 }

 location = /500.html { }

 location ~* \.(jpg|jpeg|gif)$ {
     expires     30d;
 }

 location ~ ^/rtorrent/.+\.php$ {
     fastcgi_pass 127.0.0.1:9000;
     auth_basic            "Restricted";
     auth_basic_user_file  /usr/local/nginx/htpasswd;
 }

 location ~ ^/rtorrent {
     auth_basic            "Restricted";
     auth_basic_user_file  /usr/local/nginx/htpasswd;
 }

 location ~ \.php$ {
     fastcgi_pass 127.0.0.1:9000;
 }


Igor S.
http://sysoev.ru/en/