Complete the code to redirect all HTTP requests to HTTPS.
if ($scheme = [1]) { return 301 https://$host$request_uri; }
We check if the scheme is 'http' to redirect to HTTPS.
Complete the code to redirect users from example.com to www.example.com.
if ($host = [1]) { return 301 https://www.example.com$request_uri; }
The condition checks if the host is 'example.com' to redirect to 'www.example.com'.
Fix the error in the code to redirect mobile users to m.example.com.
if ($http_user_agent ~* [1]) { return 302 https://m.example.com$request_uri; }
The pattern should be a plain string without quotes or slashes for the regex match.
Fill both blanks to redirect requests with query parameter 'ref=old' to '/newpage'.
if ($arg_[1] = [2]) { return 301 /newpage; }
$arg_ref accesses the 'ref' query parameter, and we check if it equals 'old' to redirect.
Fill all three blanks to redirect requests from 'example.org' with user agent containing 'Bot' to '/botpage'.
if ($host = [1]) { if ($http_user_agent ~* [2]) { return 302 [3]; } }
First check if host is 'example.org', then if user agent contains 'Bot', redirect to '/botpage'.