Saturday, 31 August 2013

Capture query parameters in nginx rewrites

Capture query parameters in nginx rewrites

I saw an nginx rewrite rule that captured the query parameters from the
URL and applied the same query parameters to the rewritten URL. I can
understand that in some circumstances it could/would be beneficial to
capture the query parameters in the rewrite rule, but it seems to me that
in this situation doing so is pointless.
The rewrite rule in question is as follows:
rewrite ^/users/(\d+)\.html(?:\?(.*))?$ /users/profile.php?id=$1&$2 last;
Is this pointless as I suspect? I believe that the following rewrite rule
would have the same effect:
rewrite ^/users/(\d+)\.html$ /users/profile.php?id=$1 last;

No comments:

Post a Comment