Nginx - Customizing 404 page

后端 未结 5 2221
无人共我
无人共我 2020-12-07 10:29

Nginx+PHP (on fastCGI) works great for me. When I enter a path to a PHP file which doesn\'t exist, instead of getting the default 404 error page (which comes for any invalid

5条回答
  •  -上瘾入骨i
    2020-12-07 10:52

    These answers are no longer recommended since try_files works faster than if in this context. Simply add try_files in your php location block to test if the file exists, otherwise return a 404.

    location ~ \.php {
        try_files $uri =404;
        ...
    }
    

提交回复
热议问题