0
0
Nginxdevops~10 mins

Try_files directive 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 use try_files to check for the requested file or fallback to index.html.

Nginx
try_files $uri [1];
Drag options to blanks, or click blank then click option'
A$uri/ /index.html;
B$uri/ /index.html
C$uri/ /index.htm
D$uri /index.html
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a semicolon inside the try_files argument
Using incorrect fallback file name
Missing spaces between file paths
2fill in blank
medium

Complete the code to try the requested URI, then the URI with a trailing slash, then fallback to /index.php.

Nginx
try_files $uri [1] /index.php;
Drag options to blanks, or click blank then click option'
A$uri/
B$uri//
C$uri/index.php
D$uri/index.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using double slashes which is invalid
Trying a file instead of a directory for the second option
3fill in blank
hard

Fix the error in the try_files directive to properly fallback to /404.html if files are not found.

Nginx
try_files $uri $uri/ [1];
Drag options to blanks, or click blank then click option'
A/404.html
B404.html
C/404
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Using relative path without leading slash
Using just status code instead of file path
4fill in blank
hard

Fill both blanks to try the requested URI, then the URI with index.html, then fallback to /fallback.html.

Nginx
try_files [1] [2] /fallback.html;
Drag options to blanks, or click blank then click option'
A$uri
B$uri/index.html
C$uri/
D/index.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using $uri/ instead of $uri/index.html
Missing leading slash in fallback
5fill in blank
hard

Fill all three blanks to try the URI, then URI with trailing slash, then URI with index.php, falling back to /default.php.

Nginx
try_files [1] [2] [3] /default.php;
Drag options to blanks, or click blank then click option'
A$uri
B$uri/
C$uri/index.php
D/index.php
Attempts:
3 left
💡 Hint
Common Mistakes
Using absolute path in the second or third try
Missing trailing slash in second try