url rewrite help

Igor Sysoev is at rambler-co.ru
Sat Dec 8 21:17:30 MSK 2007


On Sat, Dec 08, 2007 at 10:01:36AM -0800, rkmr.em at gmail.com wrote:

> On Dec 8, 2007 9:45 AM, Igor Sysoev <is at rambler-co.ru> wrote:
> 
> > On Sat, Dec 08, 2007 at 09:31:49AM -0800, rkmr.em at gmail.com wrote:
> > > i am moving from lighttpd to nginx, and I had this rewrite in lighttd.
> > how
> > > do i do this in nginx?
> > >    "^/[^/]+\.xml$" => "/static$0",
> > > i tried and dint work
> > >   rewrite    ^/[^/]+\.xml$  /static$1;
> > You do not need rewrite. Try to avoid a rewrite as much as possible.
> >     location ~ ^/[^/]+\.xml$ {
> >         root   /path/to/static;
> >     }
> 
> this has to be in server section right? if i want this common for all
> virtual hosts, how do i do it?

The rewrites may be used inside server section only too.
And this was done intentionally: some day you will want to add site
where this global rewrite will interfere and you have to move
the rewrite to all sites except new one.

I had deal with many legacy Apache configuraitons with lot of global
<Location>s, <Files>, <Directory>s, and RewriteRule's.
It's really hard to add new sites in such configuraitons.

Do scalable configuraiton from the very start.


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





More information about the nginx mailing list