简体   繁体   English

禁用直接访问 nginx 自定义错误页面

[英]Disable direct access to nginx custom error page

I have this nginx block that redirects all 401,403 and 404 to a single custom error page我有这个 nginx 块将所有 401,403 和 404 重定向到单个自定义错误页面

error_page 401 @errorPage;
error_page 403 @errorPage;
error_page 404 @errorPage;
location @errorPage {
    rewrite ^ /error.php?error=$status last;
}

Is it possible to deny the access to the error.php if called directly?如果直接调用,是否可以拒绝访问error.php? Thanks谢谢

Consider storing error pages outside of the main web folder and set a new root or alias :考虑将错误页面存储在主 web 文件夹之外并设置新的rootalias

location @errorPage {
  root /var/www/error-pages;
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM