Custom 404 and 500 errors not working

孤街浪徒 提交于 2019-12-12 05:38:43

问题


Got custom 404 and 500 error pages which don't work. I'm given the following error for both pages, when trying to access directly or via error: error img


.htaccess content:

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

ErrorDocument 404 /error_docs/404.php
ErrorDocument 500 /error_docs/500.php

error pages both contain:

<p>text</p>

I've checked both paths several times and they are correct. If i substitute the file paths for text, the text is displayed and the error works. Thanks.


回答1:


Remove this line and finally you are ready

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]



回答2:


As an example in XAMPP whe you use ErrorDocument it redirects to the localhost folder. If I write:

ErrorDocument 404 /error_docs/404.php

It redirects to:

localhost/error_docs/404.php

In fact the ErrorDocument always redirects to the DocumentRoot

So the best way (I know right now) to do it is with an absolute path



来源:https://stackoverflow.com/questions/37420282/custom-404-and-500-errors-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!