当前位置:编程学习 > 网站相关 >>

自定义404错误页

目录

   1. What is 404 什么是404
   2. 创建一个。htaccess文件
   3. 在custom404页
   4. 例如custom404页

什么是404。

.您有多个看到404 1 brazillian时候对净戳可能。 .往往这些网页定制公司网站的设计,以混合英寸当使用标准的404页没有什么信息,以帮助用户进一步浏览您的网站。通过提供自定义404页,用户可以显示出地图或其他方法,直接到您的网站回来。.首先,我们将使用Apache和htaccess来创造我们的404和PHP的信息,提供自定义404页的内容。

创建一个。htaccess文件

.它已经超出了本文的范围来描述运作的。htaccess,因此,如果您需要更多的信息,然后检查了Apache的文档。

在这里我们将使用。htaccess文件对乘坐在httpd.conf文件中指定的默认行为。.这条线将告诉Apache服务器,利用本身的custom404.php文件,而不是默认的。

ErrorDocument 404 / custom404.php

Custom404页

该custom404.php文件就像其它任何PHP您网站上的文件。它可以包含任何HTML和PHP等混合您选择。 .您可以控制的内容完全控制了。 这将是一个简单的任务,在一个简单的重定向提出如下所示:  

<?php
header ( "Location: http://226511.cn" );
?>

<meta name="robots" content="noindex, nofollow">

例如Custom404页

这就是不正确的做法,例如PHPRO无文章代码。 下面是一个什么样的custom404.php网页可能看起来像简单的例子

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta name="robots" content="noindex, nofollow">
<title>PHPRO Custom 404</title>
</head>
<body>
<h1>Page Not found</h2>
<p>The page you have have looked for does not exists.
Please select from the menu or search for information using the search box below
</p>

<?php
/*** lots of code for generating a sitemap ***/
?>

<form action="search.php" method="post">
<input type="text" name="search_text" />
<input type="submit" value="Search" />
</form>

补充:网页制作,设计基础 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,