Portál AbcLinuxu, 17. července 2025 18:29
ErrorDocument 400 /x/error.php ErrorDocument 401 /x/error.php ErrorDocument 402 /x/error.php ErrorDocument 403 /x/error.php ErrorDocument 404 /x/error.php ErrorDocument 405 /x/error.php ErrorDocument 406 /x/error.php ErrorDocument 407 /x/error.php ErrorDocument 408 /x/error.php ErrorDocument 409 /x/error.php ErrorDocument 410 /x/error.php ErrorDocument 411 /x/error.php ErrorDocument 412 /x/error.php ErrorDocument 413 /x/error.php ErrorDocument 414 /x/error.php ErrorDocument 415 /x/error.php ErrorDocument 500 /x/error.php ErrorDocument 501 /x/error.php ErrorDocument 502 /x/error.php ErrorDocument 503 /x/error.php ErrorDocument 504 /x/error.php ErrorDocument 505 /x/error.php ErrorDocument 506 /x/error.phpPotom v adresáři, kde se nachází kořen WWW serveru (třeba
/var/www/htdocs
, lze vytvořit soubor x/error.php
a do něj vložit následující kód:
"Bad Request", 401=>"Unauthorized", 402=>"Payment Required", 403=>"Forbidden", 404=>"Not Found", 405=>"Method Not Allowed", 406=>"Not Acceptable", 407=>"Proxy Authentication Required", 408=>"Request Time-Out", 409=>"Conflict", 410=>"Gone", 411=>"Length Required", 412=>"Precondition Failed", 413=>"Request Entity Too Large", 414=>"Request-URL Too Large", 415=>"Unsupported Media Type", 500=>"Server Error", 501=>"Not Implemented", 502=>"Bad Gateway", 503=>"Out of Resources", 504=>"Gateway Time-Out", 505=>"HTTP Version not supported" ); if (IsSet($_SERVER["REDIRECT_STATUS"])) { printf("<h1>%d: %s</h1>", $_SERVER["REDIRECT_STATUS"], $http_codes_en[$_SERVER["REDIRECT_STATUS"]]); printf("Given URL: %s<br />", $_SERVER["REQUEST_URI"]); } ?>Samozřejmě není třeba řešit tuto věc v PHP ani jinak dynamicky, jen je třeba se vždy odkazovat relativní adresou v rámci WWW podstromu (
/usr/403/index.html
asi nebude dobrá cesta), nebo plnou adresou (http://něco
), připadně lze místo adresy uvést řetězec, který prohlížeč klientovi pošle, např.
ErrorDocument 404 "Soubor nenalezen."
/error/404.html
).
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.