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.
on 2012-10-16 20:44
on 2012-10-18 03:55
On 16/10/2012 2:44 PM, Ian M. Evans wrote: > > } > > /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. > I thought adding $args to the end of the try_files line would work but that appeared to mess it up more. Is there any way to get the try_files version to work like the old version? Been staring at this but I don't see how rewrite ^/galleries(/.*$|$) /galleries.php?mypath=$1 last; passes the path and additional GET variables, but the try_files version doesn't pass on the additional variables.
on 2012-10-18 04:00
On Thu, Oct 18, 2012 at 8:55 AM, Ian Evans <ianevans@digitalhit.com> wrote: > > I thought adding $args to the end of the try_files line would work but that > appeared to mess it up more. Is there any way to get the try_files version > to work like the old version? > > Been staring at this but I don't see how > rewrite ^/galleries(/.*$|$) /galleries.php?mypath=$1 last; passes the path > and additional GET variables, but the try_files version doesn't pass on the > additional variables. > From nginx.org/r/rewrite: "If a replacement string includes the new request arguments, the previous request arguments are appended after them. If this is undesired, putting a question mark at the end of a replacement string avoids having them appended, for example:"
on 2012-10-18 04:04
On Thu, Oct 18, 2012 at 8:59 AM, Edho Arief <edho@myconan.net> wrote: >> > > From nginx.org/r/rewrite: > > "If a replacement string includes the new request arguments, the > previous request arguments are appended after them. If this is > undesired, putting a question mark at the end of a replacement string > avoids having them appended, for example:" Additionally, I do indeed add $args for my try_files for wordpress: try_files $uri $uri/ /index.php?q=$uri&$args;
on 2012-10-18 04:21
On 17/10/2012 10:03 PM, Edho Arief wrote: >>> additional variables. > > try_files $uri $uri/ /index.php?q=$uri&$args; I changed the try_files to: try_files /pixcache$request_uri/index.html /galleries.php?mypath=$mypath&$args; and it worked. I had mistakenly added the $args without the '&' Will take it for a sail and make sure it keeps working. :-)
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.