# Not existant files passed to php backend

**URL:** <https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369>\
**Category:** NGINX\
**Created:** [August 20, 2008, 11:43am UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369 "2008-08-20T11:43:14Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [August 20, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369/21 "2008-08-20T21:51:48Z")

</div>

On Wed, Aug 20, 2008 at 12:18:42PM -0400, Sean A. wrote:

> Such as?

1. Only some directives are allowed inside “if” block.

2. If you have two or more “if” blocks and their conditions are true,  
then  
only last block configuration will be used, they are not merged as  
one  
may expect:

> Our entire setup is built around these right now.

Could you show example of the setup ?

---

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [August 20, 2008, 9:58pm UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369/22 "2008-08-20T21:58:51Z")

</div>

On Wed, Aug 20, 2008 at 11:40:18PM +0400, Igor S. wrote:

> > > No, they does not impact the perfomance, but they has many limits  
> > > if (true) {  
> > > configuration A  
> > > }
> 
> ```
> if (true again) {
> configuration B # only this configuration will be used
> }
> 
> ```

However, this does not apply to ngx\_http\_directive: rewrite, return, and  
set:  
they will be executed in both configuration: A an B. And this may  
confuse too.

---

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [August 20, 2008, 10:07pm UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369/23 "2008-08-20T22:07:39Z")

</div>

On Wed, Aug 20, 2008 at 11:49:59PM +0400, Igor S. wrote:

> > > > > If so, how much ?  
> > > > > may expect:  
> > > > > they will be executed in both configuration: A an B. And this may confuse too.  
> > > > > -ngx\_http\_directive  
> > > > > +ngx\_http\_rewrite\_module directives

---

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [August 21, 2008, 1:04am UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369/24 "2008-08-21T01:04:33Z")

</div>

> > Our entire setup is built around these right now.
> 
> Could you show example of the setup ?

there is a good bit of cruft in this as it has built up over 18 months  
and was started when i knew basically zip about nginx.  
its also very site specific ( our software does amusing things with  
urls… ), kind of the uri equivalent of how i abused strings  
in the if statements below to simulate ‘and’ for nginx if.

that said, here are the important parts… as noted, its all built  
around if statements… largely because  
this all is already inside location blocks ( i can provide more  
context if you need. )

set $dynamic 0;  
set $handler “lp”;  
set $real\_file $request\_filename;

if ( $uri ~\* ^/s-([^/]_)/(._)$ )  
{  
set $has\_lid 1;  
set $lid $1;  
set $handler $2;  
set $real\_file $document\_root/$handler;  
}

# dynamics

if ( !-e $real\_file )  
{  
set $dynamic 1;  
}

if ( -e $real\_file/index.i )  
{  
set $dynamic 1;  
}

if ( $real\_file ~\* .(i|pl)$ )  
{  
set $dynamic 1;  
}

# next 6 lines required if no site has setup any geotargeting

if ( $geotarget = 0 )  
{  
set $geotarget 0;  
set $geotarget\_domain 0;  
set $geotarget\_lid 0;  
}  
set $dyn\_geo “$dynamic:$geotarget”;  
if ( $dyn\_geo = ‘1:1’ )  
{  
rewrite (.\*) http://micro.$geotarget\_domain/s-  
$geotarget\_lid&subid=$lid/$handler redirect;  
break;  
}

if ( $dynamic )  
{  
error\_page 404 = @memcache;  
break;  
}

if ( $has\_lid )  
{  
rewrite ^(/s-[^/]_/)(._)$ /$2;  
}

---

<div class="post-metadata">

**Author:** ![Reinis\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@Reinis\_R](https://www.ruby-forum.com/u/Reinis_R)\
**Post date:** [August 21, 2008, 11:10am UTC](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369/25 "2008-08-21T11:10:43Z")

</div>

On Wed, Aug 20, 2008 at 06:57:52PM -0400, Sean A. wrote:

> {  
> }
> 
> ```
> rewrite (.*) http://micro.$geotarget_domain/s- 
> 
> ```
> 
> if ( $has\_lid )  
> {  
> rewrite ^(/s-[^/]_/)(._)$ /$2;  
> }

Your configuration is good in general.  
The set’s are intended for use in “if”.

[Previous page](https://www.ruby-forum.com/t/not-existant-files-passed-to-php-backend/146369.md?page=1)
