How to style 404 page in WAMP server

2019-02-13 23:23发布

I am using a WAMP server and I need to change the "404 not found page" style using CSS. How can I do it?

enter image description here

5条回答
Root(大扎)
2楼-- · 2019-02-13 23:25

In your httpd.conf file, there will be an ErrorDocument section:

#
# 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
#

After that, add this code:

ErrorDocument 404 /error.html

That will set the error page to a file called error.html, and it is better than using .htaccess files.

查看更多
爷、活的狠高调
3楼-- · 2019-02-13 23:30

In .htaccess add

ErrorDocument 404 /path/to/custom/404.php
查看更多
对你真心纯属浪费
4楼-- · 2019-02-13 23:36

This is a core feature in Apache, and you can select a few methods of changing the 404 message.

To create your own custom page with HTML/CSS, this is one option you can put in your .htaccess file:

ErrorDocument 404 /my404.php
查看更多
不美不萌又怎样
5楼-- · 2019-02-13 23:40

You can redirect 404 error pages using .htaccess file to your custom pages.

Design your custom 404 page with using HTML/CSS. Once you have your 404 page setup, all you need to do is send visitors to incorrect url’s to this page. To do this just add the following line to your .htaccess file:

ErrorDocument 404 /404.php

You can place the 404 error template anywhere you want. For example you could place all error messages in a folder called errormessages

ErrorDocument 404 /errormessages/404.php 

See this article, How to redirect your 404 error to a custom page

查看更多
【Aperson】
6楼-- · 2019-02-13 23:43

if there are many sites hosted on your server and you want a different message for each site, adding ErrorDocument 404 to .htaccess file is the way to go.

If you want the same error message to occur across all the websites, then setting ErrorDocument in httpd.conf is the way to go.

查看更多
登录 后发表回答