我打开了apache重写引擎模块,并在.htaccess文件中以这种方式配置了自定义404错误页面: ErrorDocument 404 /not_found.php
当我尝试访问某些不存在的页面时,会显示404错误页面。我的问题是我希望更新地址栏上的URL而不是不存在的URL。我怎样才能做到这一点?感谢
答案 0 :(得分:1)
这样可行: htaccess的:
ErrorDocument 404 /my404redirect.htm
my404redirect.htm:
<html>
<head>
<meta http-equiv="refresh" content="0;URL=/not_found.php" />
</head>
</html>
这将显示404 my404redirect.htm,它将用户重定向到你not_found.php。这不是最好的方式,但它工作快速而简单。你还应该添加一个 的robots.txt 一行,以防止搜索引擎显示您的404文件。