自定义 404 和 500 错误不起作用
Custom 404 and 500 errors not working
获得了无效的自定义 404 和 500 错误页面。尝试直接访问或通过错误访问时,两个页面都出现以下错误:
error img
.htaccess 内容:
DirectoryIndex index.php
RewriteEngine on
RewriteCond !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/ [L,QSA]
ErrorDocument 404 /error_docs/404.php
ErrorDocument 500 /error_docs/500.php
错误页面均包含:
<p>text</p>
我已经多次检查这两条路径,它们都是正确的。
如果我将文件路径替换为文本,则会显示文本并且错误会出现。
谢谢
去掉这一行,你终于准备好了
RewriteRule ^(.*)$ ./index.php/ [L,QSA]
作为 XAMPP 中的示例,当您使用 ErrorDocument 时,它会重定向到
本地主机文件夹。如果我写:
ErrorDocument 404 /error_docs/404.php
重定向到:
localhost/error_docs/404.php
实际上 ErrorDocument 总是重定向到 DocumentRoot
所以最好的方法(我现在知道)是使用绝对路径
获得了无效的自定义 404 和 500 错误页面。尝试直接访问或通过错误访问时,两个页面都出现以下错误:
error img
.htaccess 内容:
DirectoryIndex index.php
RewriteEngine on
RewriteCond !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/ [L,QSA]
ErrorDocument 404 /error_docs/404.php
ErrorDocument 500 /error_docs/500.php
错误页面均包含:
<p>text</p>
我已经多次检查这两条路径,它们都是正确的。 如果我将文件路径替换为文本,则会显示文本并且错误会出现。 谢谢
去掉这一行,你终于准备好了
RewriteRule ^(.*)$ ./index.php/ [L,QSA]
作为 XAMPP 中的示例,当您使用 ErrorDocument 时,它会重定向到 本地主机文件夹。如果我写:
ErrorDocument 404 /error_docs/404.php
重定向到:
localhost/error_docs/404.php
实际上 ErrorDocument 总是重定向到 DocumentRoot
所以最好的方法(我现在知道)是使用绝对路径