我有一个支持PHP和htaccess的网站
基本上,我想将用户输入的URL(导致404)传递到404页面本身
有办法做到这一点吗?
在.htaccess
文件中添加以下规则。
ErrorDocument 404 /error.php
在error.php
文件中。
<?php // error.php
echo $_SERVER["REQUEST_URI"]. " doesn't exists. Sorry!";
?>
只需在.htaccess文件中添加以下内容(其中404.php是错误页面)
ErrorDocument 404 /404.php
您可以在.htaccess.中添加以下规则
ErrorDocument 404 /404.php
在404.php中,您可以编写
<h3>
Page Not Found.
</h3>
<div>
<p>Apologies, but the page you requested could not be found.</p>
<ul>
<li>You may have mistyped the page address.</li>
<li>You may have clicked on a link that has not been updated.</li>
<li>We have recently changed our site structure and the page has been moved to new location.</li>
</ul>
</div>
您可以设置此样式以正确显示它。
希望这有帮助:)