我需要php的帮助 . 我正在Core Php中创建一个门户网站 . 我创建了404页面 . 和.htaccess文件 .
404.php:
<html>
<head>
<title>404 Error - Page Not Found</title>
</head>
<body>404 Error - Page Not Found!</body>
</html>
的.htaccess:
Redirect 404 /404.php
但这不起作用 . 如果我使用此代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /404.html [L]
</IfModule>
它显示内部服务器错误 .
6 回答
在.htaccess中试试这个:
这里,ErrorDocument将所有404重定向到特定的URL
重写规则将该URL映射到实际的404.php脚本 . 如果需要,可以使RewriteCond正则表达式更通用,但我认为您必须明确定义要覆盖的所有ErrorDocument代码 .
注意:更换
将此行添加到htaccess并更改网址
htacces应该是这样的
调用函数:
您必须设置重写引擎 . 然后自定义一个php页面来处理404错误 . 请参阅以下代码
您还可以使用以下内容将所有404请求重定向到特定页面