.htaccess 如何在用户输入错误的URL时重定向到404错误页面

elcex8rz  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(94)

我正在建立一个静态Html网站。当用户第一次进入我的网站时,他/她首先被重定向到文件夹localhost/creative上的index.php,然后使用require_once处理index.php后,从localhost/creative/themes/目录中提取所有Html文件(如header.php)。在整个过程中,如果用户输入了错误的URL,我将无法重定向他/404错误页面404错误页面
在我的.htaccess文件中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /creative/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /creative/ [L]
</IfModule>

我尝试使用Error Document 404 /themes/404.php,但它不工作。如果url是错误的,谁能告诉我如何将我网站上的用户重定向到404.php?我希望在php中进行处理。

o2rvlv0m

o2rvlv0m1#

代替

Error Document 404 /themes/404.php

用途

ErrorDocument 404 /themes/404.php

相关问题