如何为apache中的所有用户创build自定义404错误页面?

我需要创build404错误页面,但它应该是所有用户都可以使用,如果我使用ErrorDocument 404 / 404.php它将显示“ 另外,尝试使用ErrorDocument处理请求时遇到404未find错误。 “在用户的网站上,如何创build它,而不是在每个用户documentroot放置404.php?

你可以用上面的重写规则来configuration你的apache:

ErrorDocument 404 http://www.domain.com/customerrors/page-404.html # or maybe .php if you want some smarts in that page? 

还要为/ customerrors /path放置一个系统范围的别名

 Alias /customerrors /var/www/html/custom-errors/ <Directory /var/www/html/custom-errors/> # make sure the location can be used to serve files Order allow,deny Allow from all </Directory> 

你只需要小心不要覆盖一个网站的本地URL。

用重写规则configuration你的Apache

 ErrorDocument 404 http://www.domain.com/custom/page-404.html