Welcome! Log In Create A New Profile

Advanced

Re: regex rewrite problem

Edho Arief
January 18, 2012 10:56PM
On Thu, Jan 19, 2012 at 10:46 AM, mpratt <nginx-forum@nginx.us> 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:

/manufacturers/a/something

and not:

/manufacturers/asdfgh/something

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 - www.asciiribbon.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

regex rewrite problem

mpratt January 18, 2012 05:02PM

Re: regex rewrite problem

Alexander Kolesen January 18, 2012 05:34PM

Re: regex rewrite problem

mpratt January 18, 2012 07:31PM

Re: regex rewrite problem

António P. P. Almeida January 18, 2012 08:50PM

Re: regex rewrite problem

mpratt January 18, 2012 10:46PM

Re: regex rewrite problem

Edho Arief January 18, 2012 10:56PM

Re: regex rewrite problem

mpratt January 19, 2012 08:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 72
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready