try_files rewrite drops other get variables

Ian Evans ianevans at digitalhit.com
Thu Oct 18 02:21:08 UTC 2012


On 17/10/2012 10:03 PM, Edho Arief wrote:
> On Thu, Oct 18, 2012 at 8:59 AM, Edho Arief <edho at myconan.net> wrote:
>> On Thu, Oct 18, 2012 at 8:55 AM, Ian Evans <ianevans at 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:"
>
> Additionally, I do indeed add $args for my try_files for wordpress:
>
> 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. :-)



More information about the nginx mailing list