# Password protecting folder breaks PHP within that folder

**URL:** <https://www.ruby-forum.com/t/password-protecting-folder-breaks-php-within-that-folder/179756>\
**Category:** NGINX\
**Created:** [December 3, 2009, 7:39am UTC](https://www.ruby-forum.com/t/password-protecting-folder-breaks-php-within-that-folder/179756 "2009-12-03T07:39:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b2d939/32.png) [@raab](https://www.ruby-forum.com/u/raab)\
**Post date:** [December 3, 2009, 7:39am UTC](https://www.ruby-forum.com/t/password-protecting-folder-breaks-php-within-that-folder/179756/1 "2009-12-03T07:39:38Z")

</div>

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](http://raab.ftw.net.nz/nginx.conf)

Posted at Nginx Forum:

> **[Password protecting folder breaks PHP within that folder](https://forum.nginx.org/read.php?2,27597,27597#msg-27597)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![raab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b2d939/32.png) [@raab](https://www.ruby-forum.com/u/raab)\
**Post date:** [December 4, 2009, 8:34am UTC](https://www.ruby-forum.com/t/password-protecting-folder-breaks-php-within-that-folder/179756/2 "2009-12-04T08:34:29Z")

</div>

## Igor S. Wrote:

> > 
> 
> ```
> index index.php;
> auth_basic "Restricted";
> location ~ \.php$ {
> 
> ```
> 
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

That works brilliantly, thanks for that 🙂

Cheers,  
James

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,27597,27603#msg-27603](http://forum.nginx.org/read.php?2,27597,27603#msg-27603)

---

<div class="post-metadata">

**Author:** ![raab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b2d939/32.png) [@raab](https://www.ruby-forum.com/u/raab)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/password-protecting-folder-breaks-php-within-that-folder/179756/3 "2009-12-19T15:25:27Z")

</div>

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: [Redirecting...](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.

> **[Igor Sysoev](http://sysoev.ru/en/)**
