# Help with rewrite

**URL:** <https://www.ruby-forum.com/t/help-with-rewrite/211464>\
**Category:** NGINX\
**Created:** [September 5, 2011, 12:46am UTC](https://www.ruby-forum.com/t/help-with-rewrite/211464 "2011-09-05T00:46:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 5, 2011, 12:46am UTC](https://www.ruby-forum.com/t/help-with-rewrite/211464/1 "2011-09-05T00:46:37Z")

</div>

Hi everyone,

I am using a plugin for my site called VBSEO

They use the following code:

* * *

## if ($request\_filename ~ “.php$” ) { rewrite ^/(._)$ /vbseo.php break; } if (!-e $request\_filename) { rewrite ^/(._)$ /vbseo.php break; }

I read the article about IF IS EVIL and thought it would be better to  
make this code better.

Could someone who knows about the rewrites and nginx coding please help  
me.

I will post the results (if it’s possible of course) to VBSEO so they  
can update there rules.

Kind Regards  
Mick

Posted at Nginx Forum:

> **[Help with rewrite](https://forum.nginx.org/read.php?2,214761,214761#msg-214761)**
>
> Hi everyone, I am using a plugin for my site called VBSEO They use the following code: -------------------------------------------------------- if ($request\_filename ~ "\\.php$" ) { rewrite ^/(.\*)$ /vbseo.php break; }

---

<div class="post-metadata">

**Author:** ![Mickie\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@Mickie\_D](https://www.ruby-forum.com/u/Mickie_D)\
**Post date:** [September 5, 2011, 8:13pm UTC](https://www.ruby-forum.com/t/help-with-rewrite/211464/2 "2011-09-05T20:13:51Z")

</div>

the first “if” can be replaced with the following:

location ^.+.php$ {  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME $document\_root/vbseo.php;  
fastcgi\_pass …; # your fastcgi handler  
}

not sure that the second “if” is needed, unless they meant to handle all  
non-existing files (404 errors) with vbseo.php. this can be done with  
the following:

location / {  
error\_page 404 = /vbseo.php;  
}

Andrejs

Posted at Nginx Forum:

> **[Re: Help with rewrite](https://forum.nginx.org/read.php?2,214761,214833#msg-214833)**
>
> Hi everyone, I am using a plugin for my site called VBSEO They use the following code: -------------------------------------------------------- if ($request\_filename ~ "\\.php$" ) { rewrite ^/(.\*)$ /vbseo.php break; }
