Recall & Review
beginner
What is the purpose of the
rewrite directive in nginx?The
rewrite directive changes the requested URL before nginx processes it further. It helps redirect or modify URLs based on patterns.Click to reveal answer
beginner
How do you write a basic
rewrite rule to redirect /old to /new?Use
rewrite ^/old$ /new permanent; to redirect requests from /old to /new with a permanent redirect.Click to reveal answer
intermediate
What does the
last flag do in a rewrite rule?The
last flag stops processing current rewrite rules and restarts location search with the new rewritten URL.Click to reveal answer
intermediate
Explain the difference between
permanent and redirect flags in rewrite.permanent sends a 301 status (permanent redirect), while redirect sends a 302 status (temporary redirect).Click to reveal answer
intermediate
What happens if you omit flags in a rewrite directive?
If no flag is given, nginx uses
last by default, rewriting the URL and restarting location search.Click to reveal answer
Which flag in the nginx rewrite directive causes a permanent redirect?
✗ Incorrect
The
permanent flag sends a 301 status code indicating a permanent redirect.What does the
rewrite ^/old$ /new last; directive do?✗ Incorrect
The
last flag restarts location search after rewriting the URL.If you want to temporarily redirect a URL in nginx, which flag should you use?
✗ Incorrect
The
redirect flag sends a 302 temporary redirect.What is the default behavior if no flag is specified in a rewrite directive?
✗ Incorrect
By default, nginx uses the
last flag if no flag is given.Which directive is used to modify URLs before nginx processes them?
✗ Incorrect
The
rewrite directive changes URLs before further processing.Describe how the nginx rewrite directive works and when you would use it.
Think about changing URLs before nginx serves content.
You got /4 concepts.
Explain the difference between the 'last' and 'break' flags in nginx rewrite rules.
Consider how nginx continues or stops processing after rewriting.
You got /3 concepts.