如何在WAMP服务器中设置404页面样式

时间:2012-08-01 06:46:01

标签: php html css http-status-code-404 wamp

我正在使用WAMP服务器,我需要使用CSS更改“404 not found page”样式。我该怎么办?

enter image description here

5 个答案:

答案 0 :(得分:5)

httpd.conf文件中,会有一个ErrorDocument部分:

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

之后,添加以下代码:

ErrorDocument 404 /error.html

这会将错误页面设置为名为error.html的文件,并且优于使用.htaccess文件。

答案 1 :(得分:2)

您可以使用.htaccess文件将404错误页面重定向到自定义页面。

使用HTML / CSS设计自定义 404 页面。完成404页面设置后,您只需将访问者发送到此页面的错误网址即可。要执行此操作,只需将以下行添加到.htaccess文件中:

ErrorDocument 404 /404.php

您可以将 404 错误模板放在任意位置。例如,您可以将所有错误消息放在名为errormessages

的文件夹中
ErrorDocument 404 /errormessages/404.php 

请参阅此文章How to redirect your 404 error to a custom page

答案 2 :(得分:2)

这是Apache中的 core feature ,您可以选择一些更改404消息的方法。

要使用HTML / CSS创建自己的自定义页面,可以在.htaccess文件中添加一个选项:

ErrorDocument 404 /my404.php

答案 3 :(得分:2)

在.htaccess中添加

ErrorDocument 404 /path/to/custom/404.php

答案 4 :(得分:0)

如果您的服务器上托管了许多网站,并且您希望为每个网站添加不同的消息,请添加 ErrorDocument 404 到.htaccess文件是可行的方法。

如果您希望在所有网站上都出现相同的错误消息,那么在httpd.conf中设置ErrorDocument即可。