问题
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