Welcome! Log In Create A New Profile

Advanced

try_files rewrite drops other get variables

Ian M. Evans
October 16, 2012 02:46PM
A couple of wees ago in "Updating some old 'if' statements"
(http://forum.nginx.org/read.php?2,231164,231164#msg-231164) it was
suggested I use try files instead of the 'if' I had.

The old location did two things: It ran an extensionless file as a php
file and also checked for the existence of a statically cached file.

Though the rewrite is successfully serving the static file and handling
the extensionless php fine, I didn't initially notice that other GET
variables like ?page are getting ignored.

Here's the old 'if' location that passed on all variables just fine:

old:
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;
}

and the current location with try_files

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

Those familiar with my posts know I suck at regex, but I'm assuming the
rewrite in the old location successfully took URLS like:

/galleries/129/1/3?page=2 and passed them to php as:
/galleries.php?mypath=/129/1/3&page=2 while something in the new location
is dropping any additional get variables?

The old location has been working successfully in production for several
years but I thought I should get rid of the evil if.

The try_files version, as I said, works except for the dropping of
additional get variables in the URL.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

try_files rewrite drops other get variables

Ian M. Evans October 16, 2012 02:46PM

Re: try_files rewrite drops other get variables

Ian Evans October 17, 2012 09:56PM

Re: try_files rewrite drops other get variables

Edho Arief October 17, 2012 10:00PM

Re: try_files rewrite drops other get variables

Edho Arief October 17, 2012 10:04PM

Re: try_files rewrite drops other get variables

Ian Evans October 17, 2012 10:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 91
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready