regex rewrite problem

Edho Arief edho at
Thu Jan 19 03:54:41 UTC 2012

On Thu, Jan 19, 2012 at 10:46 AM, mpratt <nginx-forum at> wrote:
> Thanks for your reply. I had previously read that section and enclosed
> them in quotes and it didn't work:
> for example:
>> location ~* /manufacturers/ {
>> rewrite "^/manufacturers/(.{1})/(.*)$" /manufacturer/directory/$1
> redirect;
>> }
> doesn't work. That;'s why I was so stumped. Thought I had done
> everything according to that section...

Of course it won't. The regex above will only match url like this:


and not:


Because /(.{1})/ will only match (and capture) one character between
two slashes (e.g. /u/, /b/) while /(.).*/ will match (and capture)
first character of word between two slashes (e.g. /unix/, /books/).

O< ascii ribbon campaign - stop html mail -

More information about the nginx mailing list