Updating some old "if" statements

A few years back this list helped me create some locations that allowed
some extensionless files to run as php and pass the rest of their path
along as a variable. I’m wondering if there’s been any changes or tweaks
over the years that would make these locations run less efficiently than
they could be. As I’m reading this more I’m seeing “If is evil” right?

Location #1:

location ~ /(photos|profile|review|profiles|reviews|news)(/|$) {
if ($uri ~ ^(./(photos|profile|review|profiles|reviews|news))($|/.)) {
rewrite ^(./(photos|profile|review|profiles|reviews|news))($|/.)
$1.php?mypath=$3 last;
}
}

Location #2:

location ~ ^/galleries(/.$|$) {
if (-f /usr/local/nginx/htdocs/pixcache$request_uri/index.html) {
expires 2h;
rewrite ^(.
)$ /pixcache$1/index.html last;
break;
}
rewrite ^/galleries(/.*$|$) /galleries.php?mypath=$1 last;
}

On Fri, Sep 28, 2012 at 2:35 AM, Ian M. Evans [email protected]
wrote:

rewrite ^(./(photos|profile|review|profiles|reviews|news))($|/.)
$1.php?mypath=$3 last;
}
}

just remove the if().

location ~ ^/galleries(?/.*$|$) {
expires 2h;
try_files /pixcache$mypath/index.html /galleries.php?mypath=$mypath;
}

Thanks for the new locations!

location ~ ^/galleries(?/.*$|$) {
expires 2h;
try_files /pixcache$mypath/index.html /galleries.php?mypath=$mypath;
}

I have an older PCRE with my CentOS version, so am I write in
remembering the named regex can be changed to from ? to
?P

Thanks again.

On Fri, September 28, 2012 7:15 am, Edho A. wrote:

just remove the if().
Strangely, when I removed the “if” on this one and just had the rewrite,
I
started getting 404 errors.

On Sat, Sep 29, 2012 at 8:38 AM, Ian E. [email protected]
wrote:

rewrite ^/galleries(/.*$|$) /galleries.php?mypath=$1 last;
the named regex can be changed to from ? to ?P

I also wrote it wrong, should be /pixcache$request_uri/index.html