redirect from www to sub-page

Igor Sysoev is at rambler-co.ru
Fri Jan 23 12:44:33 MSK 2009


On Thu, Jan 22, 2009 at 09:59:43PM +0100, Marcin Kasperski wrote:

> >      rewrite ^/$ /new_location;
> >
> > will run regex "^/$" for every request, while
> >
> >      location = / {
> >          rewrite ^   http://www.example.com/new_location;
> >
> > is just simple comparison with "/". And the regex "^" will be run only
> > for "/" requests.
> 
> Thanks for the explanation.
> 
> PS It could be interesting to measure how noticeable the difference
> is. Precompiled hooked regexps aren't that slow.... But I don't have
> an idea of realistic benchmark.

Regexs may differ in times than simple comparison, however it will
not be noticeable in the big picture.

BTW, if you have

      location = / {
      }

      location / {
      }

then in 0.7.x "= /" is for free.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list