URI rewriting based on arguments

B.R. reallfqq-nginx at yahoo.fr
Sat Nov 8 02:31:59 UTC 2014


Hello,

Trying to rewrite an URI based on an argument, I cannot match it otherwise
than by using rewrite.

The problem is I fail to achieve a working recipe rewriting
example.com/watch?v=123456
to
example.com/watch?vid=123456

rewrite ^/watch\?v=(?<video>\d+)$ $scheme://$host$uri?vid=$video?
does not seem to work

rewrite ^/watch\? $scheme://$host$uri?vid=blah?
does not either

rewrite ^/watch $scheme://$host$uri?vid=blah?;
works, though it explodes internal rewrites (which is not our concern here).

The question mark in the first recipe seems to wreak havoc.

   1. Is there any other mean to achieve such a redirection than using
   rewrite?
   2. How to escape a question mark in a rewrite mask, ince escaping
   perl-like does not seem to work?

​Thanks,​
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141108/760280f8/attachment.html>


More information about the nginx mailing list