regex rewrite problem

António P. P. Almeida appa at perusio.net
Thu Jan 19 01:47:44 UTC 2012


On 19 Jan 2012 00h31 WET, nginx-forum at nginx.us wrote:

> Brilliant! It works perfectly. Do you have any idea why the curly
> braces didn't work and also where I can learn when to use a location
> in a location? Thank you so much!

Regexes with curly braces have to be quoted.

From the wiki: http://wiki.nginx.org/HttpRewriteModule#rewrite

     Note: for curly braces ('{' and '}'), as they are used both in
     regexes and for block control, to avoid conflicts, regexes with
     curly braces are to be enclosed with double quotes (or single
     quotes). For example, to rewrite URLs like

     rewrite  "/photos/([0-9] {2})([0-9] {2})([0-9] {2})" /path/to/photos/$1/$1$2/$1$2$3.png;

--- appa



More information about the nginx mailing list