繁体   English   中英

使用PHP和htaccess处理错误页面

[英]handle error pages using PHP and htaccess

我想在我的htaccess文件中输入如下代码:

ErrorDocument 403 /error/403
ErrorDocument 404 /error/404
ErrorDocument 500 /error/500
...

并有一个PHP文件,该文件使用GET为我处理错误页面(file.php?a = 404)。

现在,我只需要htaccess代码即可将“ / error / 404”重写为“ file.php?a = 404”。 我该怎么办 ?!

您可能还希望自定义其他一些错误文档。 400-错误的请求401-需要授权403-禁止的目录404-找不到页面500-内部服务器错误

对于您要使用的每个文件,只需在.htaccess文件中添加一行,然后创建相应的页面。

ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
ErrorDocument 404 /path/to/file.php?a=404
ErrorDocument 404 /path/to/yourfile.php

暂无
暂无

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

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