# Single php file location match

**URL:** <https://www.ruby-forum.com/t/single-php-file-location-match/184609>\
**Category:** NGINX\
**Created:** [March 5, 2010, 5:34am UTC](https://www.ruby-forum.com/t/single-php-file-location-match/184609 "2010-03-05T05:34:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewrockshard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@drewrockshard](https://www.ruby-forum.com/u/drewrockshard)\
**Post date:** [March 5, 2010, 5:34am UTC](https://www.ruby-forum.com/t/single-php-file-location-match/184609/1 "2010-03-05T05:34:38Z")

</div>

How would I go about running a PHP file that is only matched by the  
request of that file? Meaning, how can someone request a file and nginx  
run this configuration ONLY when this PHP file is requested.

Here is what I have so far:

location / {  
root /www/default/;  
try\_files $uri $uri/ /index.php?q=$uri&$args;  
index index.php;  
}

location /status.php {  
#allow 192.168.1.0/24;  
deny all;  
#allow all;  
root /www/default/;  
try\_files $uri $uri/ /index.php?q=$uri&$args;  
index status.php;  
}

Basically, I’ll be setting up rules to only allow a local network  
request, but only for status.php. So how do I go about allowing this  
one network to status.php?

Posted at Nginx Forum:

> **[Single php file location match](https://forum.nginx.org/read.php?2,60179,60179#msg-60179)**
>
> How would I go about running a PHP file that is only matched by the request of that file? Meaning, how can someone request a file and nginx run this configuration ONLY when this PHP file is requested. Here is what I have so far: \[code\] location / {

---

<div class="post-metadata">

**Author:** ![drewrockshard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@drewrockshard](https://www.ruby-forum.com/u/drewrockshard)\
**Post date:** [March 5, 2010, 9:12am UTC](https://www.ruby-forum.com/t/single-php-file-location-match/184609/2 "2010-03-05T09:12:20Z")

</div>

On Thu, Mar 04, 2010 at 11:34:19PM -0500, drewrockshard wrote:

> Basically, I’ll be setting up rules to only allow a local network request, but only for status.php. So how do I go about allowing this one network to status.php?  
> location = /status.php {  
> #allow 192.168.1.0/24;  
> deny all;  
> #allow all;  
> root /www/default/;  
> fastcgi\_pass …  
> include fastcgi.conf;  
> }

–  
Igor S.

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

---

<div class="post-metadata">

**Author:** ![drewrockshard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@drewrockshard](https://www.ruby-forum.com/u/drewrockshard)\
**Post date:** [March 5, 2010, 2:24pm UTC](https://www.ruby-forum.com/t/single-php-file-location-match/184609/3 "2010-03-05T14:24:20Z")

</div>

Igor,

Thanks for the update! This resolved it. So, after I had submitted my  
post I did end up using the equal sign (“=”), which worked, however, it  
wasn’t working, but after inserting the fcgi stuff, it worked.

Thanks again!

Posted at Nginx Forum:

> **[Re: Single php file location match](https://forum.nginx.org/read.php?2,60179,60301#msg-60301)**
>
> How would I go about running a PHP file that is only matched by the request of that file? Meaning, how can someone request a file and nginx run this configuration ONLY when this PHP file is requested. Here is what I have so far: \[code\] location / {
