Forum: NGINX Rewrite Rules

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C2582289760ac1c443711b20e53f1d06?d=identicon&s=25 Paul Greenwood (Guest)
on 2009-02-17 16:00
(Received via mailing list)
Are the rewrite rules processed in the order they are listed in the
nginx.conf file or does nginx put them in the correct order when nginx
is
started up?

Thanks
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-02-17 18:19
(Received via mailing list)
On Tue, Feb 17, 2009 at 07:48:30AM -0700, Paul Greenwood wrote:

> Are the rewrite rules processed in the order they are listed in the
> nginx.conf file or does nginx put them in the correct order when nginx is
> started up?

nginx processes if/set/rewrite in following order:

1) server level rules;
2) then locaiton level rules;
   if a matching rewrite rule has no break flag,
   then nginx searches a new location and go to (2),
   i.e. runs location level rules.

On given level rules are processed in the order they are listed.

Example for request "/":

       server {

           rule1

           location / {
               rule3
               rule4
           }

           location ~ \.php$ {
               rule5
           }

           rule2

rule1, rule2,
rule3, rule4; rule4 rewrites to index.php;
rule5
C2582289760ac1c443711b20e53f1d06?d=identicon&s=25 Paul Greenwood (Guest)
on 2009-02-17 20:07
(Received via mailing list)
Thank You
This topic is locked and can not be replied to.