Complete the code to rewrite the URL path to /home.
rewrite [1] /home break;
The rewrite directive uses a regular expression to match the URL path. The caret (^) and dollar ($) signs mark the start and end of the string, so ^/oldpath$ matches exactly the path /oldpath.
Complete the code to redirect all requests from /old to /new permanently.
return [1] /new;
HTTP status code 301 means permanent redirect. It tells browsers and search engines that the resource has moved permanently to the new URL.
Fix the error in the location block to match URLs starting with /app.
location [1] {
proxy_pass http://backend;
}The location directive with ^/app/ matches URLs that start exactly with /app/. The caret (^) means start of string, and the trailing slash ensures it matches the directory path.
Fill both blanks to create a map that sets $target to /index.html if $uri is /, else $uri.
map $uri $target {
[1] /index.html;
[2] $uri;
}The map directive matches the exact string "/" to /index.html. The default keyword sets $target to $uri for all other cases.
Fill all three blanks to rewrite URLs starting with /blog to /posts and set permanent redirect.
location [1] { rewrite [2] /posts/$1 [3]; }
The location block matches URLs starting with /blog/. The rewrite uses regex ^/blog/(.*)$ to capture the rest of the path and rewrites it to /posts/$1. The permanent flag sends a 301 redirect.