simple rewrite rules

Adam Benayoun adam at
Sun May 22 04:41:59 MSD 2011

Hello everyone,
I'm trying to setup some basic rewrite rules in nginx (I'm sorry if I may be
asking obvious question but I moved my servers from apache to nginx and I
can't figure out how to write simple rewrite rules in nginx).

This is what I am trying to achieve:

I have a URL with the following arguments:

What I want to achieve is:
- When someone try to reach - it will serve
the url internally (no 301 redirect).
- When someone will try to reach it
will redirect externally (301) to

I've added 2 rewriterule at first but somehow only the first rule works, the
second won't work:

        rewrite ^/browse/(.*)$1 permanent;
        rewrite ^/(category1|category2|category3|category4)$    /browse/$1

Thanks (and sorry for asking a somewhat newbie question!)

p.s: yes, I've read this
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list