使用.htaccess自定义错误页面的问题

时间:2013-06-28 01:57:51

标签: html .htaccess

我正在尝试使用.htaccess自定义错误页面。在这个文件夹中:/home/tamp/public_html/sandbox/test,我把.htaccess文件,在里面我把这行: ErrorDocument 404 /home/tamp/public_html/sandbox/test/error.html, 然后在前端,我做了一个测试,我打开mysite/sandbox/test/te.php(te.php does not exist),但它仍然显示默认错误页面:The requested URL /test/tes.php was not found on this server。我的error.html没有显示出来。 那么这里可能出现什么问题?

1 个答案:

答案 0 :(得分:0)

使用ErrorDocument,您无法使用完整的文件系统路径:

  

URL可以以本地Web路径的斜杠(/)开头(相对于   DocumentRoot),或者是客户端可以解析的完整URL。

假设您的网站根文件夹是沙箱:

ErrorDocument 404 /test/error.html