Help with rewrite

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

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

Kind Regards

Posted at Nginx Forum:

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;


Posted at Nginx Forum: