简体   繁体   中英

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

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? Thanks

Consider storing error pages outside of the main web folder and set a new root or alias :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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