0
0
Nginxdevops~10 mins

Rewrite flags (last, break, redirect, permanent) in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to rewrite the URL and stop processing further rewrite directives.

Nginx
rewrite ^/oldpath$ /newpath [1];
Drag options to blanks, or click blank then click option'
Alast
Bredirect
Cpermanent
Dbreak
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'break' which stops rewrite but does not restart location search.
Using 'redirect' or 'permanent' which send HTTP redirects instead of internal rewrite.
2fill in blank
medium

Complete the code to rewrite the URL and send a temporary redirect to the client.

Nginx
rewrite ^/temp$ /newtemp [1];
Drag options to blanks, or click blank then click option'
Apermanent
Blast
Cbreak
Dredirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'permanent' which sends a 301 permanent redirect instead.
Using 'last' or 'break' which perform internal rewrites without redirecting the client.
3fill in blank
hard

Fix the error in the rewrite rule to send a permanent redirect to the client.

Nginx
rewrite ^/oldpage$ /newpage [1];
Drag options to blanks, or click blank then click option'
Abreak
Bpermanent
Credirect
Dlast
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redirect' which sends a temporary redirect instead.
Using 'last' or 'break' which do not send redirects to the client.
4fill in blank
hard

Fill both blanks to rewrite the URL internally and stop processing further rewrite directives.

Nginx
location /example {
    rewrite ^/example/(.*)$ /newexample/$1[1];
    [2];
}
Drag options to blanks, or click blank then click option'
Abreak
Blast
Creturn 404
Drewrite ^/old$ /new
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'last' instead of 'break' which restarts location search.
Using 'rewrite ^/old$ /new' as a directive which is invalid here.
5fill in blank
hard

Fill all three blanks to rewrite the URL with a permanent redirect and stop processing.

Nginx
server {
    listen 80;
    server_name example.com;

    location /old {
        rewrite ^/old/(.*)$ /new/$1[1];
        [2];
        [3];
    }
}
Drag options to blanks, or click blank then click option'
Alast
Breturn 301
Cpermanent
Dbreak
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'last' instead of 'break' which restarts location search.
Using 'redirect' instead of 'permanent' for permanent redirects.
Omitting the 'break' flag causing unexpected further rewrites.