将用户输入的URL通过Htaccess和PHP传递给404页面
问题描述:
我有一个PHP和htaccess支持的网站。
基本上,我想将用户输入的URL(导致404)传递给404页面本身。
有没有办法做到这一点?将用户输入的URL通过Htaccess和PHP传递给404页面
答
在您的.htaccess
文件中添加以下规则。
ErrorDocument 404 /error.php
在error.php
文件中。
<?php // error.php
echo $_SERVER["REQUEST_URI"]. " doesn't exists. Sorry!";
?>
答
只需通过添加在.htaccess以下规则添加下面的.htaccess文件(其中404.php是你的错误页)
ErrorDocument 404 /404.php
答
你可以做到这一点。
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>
您可以风格使其正常显示。
希望这会有所帮助:)
Thanks! $ _SERVER [“REQUEST_URI”]正是我所期待的。 – nondefault 2012-01-31 02:35:59