Once the last:rewrite is matched, a request will be initiated again, and only the rules in the location will be matched again.
After a match is break:rewrite, the request is not initiated and the subsequent rules are not matched.
Example:
Location/{
root HTML;
Index index.php index.html index.htm;
}
if ($request _uri ~*/cms/) {
Rewrite "^/cms/(. *) \.php"/cms/index.php break;
# The last can be used here, and the single if only once
# "If" and "(" Requires spaces
}
Location/{
root HTML;
Index index.php index.html index.htm;
if ($request _uri ~*/cms/) {
Rewrite "^/cms/(. *) \.php"/cms/index.php break;
# using last here will cause a dead loop, and the IF in the location will handle multiple
}
}
Need to be aware of URLs with question marks
Compare without "?" and add "?" URL Jump Differences for tags
Rewrite ^/test (. *) $ http://www.yourdomain.com/home permanent;
Access http://www.yourdomain.com/test?id=5 after 301 jumps the URL is
Http://www.yourdomain.com/home?id=5
Rewrite ^/test (. *) $ http://yourdomain.com/home? Permanent
Access http://www.yourdomain.com/test?id=5 after 301 jumps the URL is
Http://www.yourdomain.com/home
Reproduced in: http://liuping0906.blog.51cto.com/2516248/1301125
The difference between the last of Nginx rewrite and the break