rewrite ^/oldpath/(.*)$ /newpath/$1 last;
What is the effect of the 'last' flag in this context?
rewrite ^/oldpath/(.*)$ /newpath/$1 last;The 'last' flag tells nginx to stop processing the current rewrite directives and restart the location search with the new URI. This means nginx will try to find a new location block matching the rewritten URI.
rewrite ^/temp/(.*)$ /final/$1 break;
What is the behavior of the 'break' flag here?
rewrite ^/temp/(.*)$ /final/$1 break;
The 'break' flag stops processing further rewrite directives and continues handling the request in the current location block using the rewritten URI. It does not restart location matching.
rewrite ^/old/(.*)$ /new/$1 redirect;
What HTTP status code does nginx send to the client?
rewrite ^/old/(.*)$ /new/$1 redirect;The 'redirect' flag sends a 302 Found status code to the client, instructing it to temporarily redirect to the new URI.
rewrite ^/site/(.*)$ /website/$1 permanent;
What status code will nginx send to the client?
rewrite ^/site/(.*)$ /website/$1 permanent;The 'permanent' flag sends a 301 Moved Permanently status code to the client, indicating the resource has moved permanently.
location /app/ {
rewrite ^/app/(.*)$ /app/$1 last;
}Requests to /app/page cause a redirect loop. What is the most likely reason?
location /app/ {
rewrite ^/app/(.*)$ /app/$1 last;
}The rewrite rule rewrites /app/page to /app/page again, and with the 'last' flag nginx restarts location matching. This causes an infinite loop of rewriting the same URI.