0
0
Nginxdevops~5 mins

Rewrite flags (last, break, redirect, permanent) in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the last flag do in an nginx rewrite rule?
The last flag stops processing the current set of rewrite directives and restarts the location search with the new URI. It is like telling nginx to start fresh with the rewritten URL.
Click to reveal answer
beginner
Explain the purpose of the break flag in nginx rewrite rules.
The break flag stops processing further rewrite directives in the current location block but does not restart the location search. It keeps nginx in the current location with the rewritten URI.
Click to reveal answer
intermediate
What is the difference between redirect and permanent flags in nginx rewrites?
Both redirect and permanent send an HTTP redirect to the client. redirect sends a temporary 302 redirect, while permanent sends a permanent 301 redirect.
Click to reveal answer
intermediate
When should you use the permanent flag in nginx rewrite rules?
Use permanent when you want to tell browsers and search engines that the resource has moved permanently to a new URL. This helps with SEO and caching.
Click to reveal answer
beginner
What happens if you omit flags in an nginx rewrite directive?
If you omit flags, nginx uses the default behavior which is similar to last. It restarts the location search with the rewritten URI.
Click to reveal answer
Which nginx rewrite flag restarts the location search with the new URI?
Apermanent
Bbreak
Credirect
Dlast
What HTTP status code does the permanent flag send?
A302
B301
C404
D500
Which flag stops rewrite processing but does NOT restart location search?
Abreak
Blast
Credirect
Dpermanent
What is the default behavior if no flag is specified in a rewrite directive?
Alast
Bredirect
Cbreak
Dpermanent
Which flag sends a temporary redirect to the client?
Alast
Bbreak
Credirect
Dpermanent
Describe the behavior and use cases of each nginx rewrite flag: last, break, redirect, and permanent.
Think about how nginx handles the rewritten URL and what response it sends to the client.
You got /4 concepts.
    Explain why you might choose the 'break' flag over 'last' in an nginx rewrite rule.
    Consider how nginx processes location blocks after rewriting.
    You got /4 concepts.