in nginx.conf
I have used this
try_files $uri $uri/ /index.php;
so that when user type any url the index.php will load.
but now I have some list of url. like [blog, contact, faq]
so when user hit anything out of that url. for example, /test
I want to display the 404 page.
how can I achieve that?
here is the location block
location / {
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ /index.php;
}
2
Answers
If it’s a long list, use a
map
, but if its a short list, add extralocation
rules:If you want these rules to be subject to your
auth_basic
, either nest them within thelocation /
block, or if possible, move theauth_basic
statements into the outer block.Use the
map
block, e.g.: