How Do I Create a 404 Page for My Website?
A "404 page" is an HTML file placed on your web server that is shown instead of the standard Internet Information Services (IIS) or Apache error message. A 404 message means the user has attempted to access a web page that does not exist. To avoid losing traffic, a customized 404 page has a link to the home page and tells users that the page no longer exists. Once you've created the simple HTML file, you edit your IIS or Apache settings to point to your custom page.
Instructions
-
Create 404 Page
-
1
Open a text editor to create your 404 page. The page is in HTML format, so you can create it in something as simple as Notepad or use more advanced editors such as Notepad++ or Visual Studio.
-
2
Use the following code to create the 404 page:
<html>
<head>
<title>My 404 page</title>
</head>
<body>
You have visited a page that does not exist. <a href="my_domain.com">Click here</a> to return to the home page.
</body>
</html>This block of code is all that is needed for the 404 page. Replace "my_domain.com" with your home page. This allows users to quickly navigate to your home page, so you don't lose traffic from a missing website page.
-
-
3
Save the HTML file and upload it to your web server. Now that the file is created, you need to configure IIS to serve the customized page when a user tries to access a bad URL.
Apache Settings
-
4
Open your httpd.conf file. This file is located in the directory where you installed Apache. For typical installations, the file is located in the "/etc/httpd/conf/" directory.
-
5
Scroll down to the section labeled "ErrorDocument." If you haven't set a 404 document yet, this section may not exist. Even if it doesn't exist, you can add it to your web server properties.
-
6
Add the following directive to your httpd.conf file:
ErrorDocument <404.html>
Replace "<404.html>" with the path to your newly create 404 file. -
7
Save the httpd.conf file. Once it's saved, the Apache server will point to your customized 404 file.
IIS Settings
-
8
Click the Windows Start button and select "Control Panel." Double-click "Administrative Tools" and then double-click the "Internet Information Services (IIS)" icon. This opens your IIS console.
-
9
Right-click the website name and select "Properties." In this window, click "Custom Errors" to retrieve a list of error pages on your website.
-
10
Click the "404 Error" item and then click "Edit Properties." In the text box displayed, enter the path to your newly created 404 page. Press the "OK" button. Press the "OK" button again at the main website properties window. The IIS server is configured to use your 404 page.
-
11
Open your web browser and enter a bad URL in the address bar for your website. Your custom 404 page is displayed.
-
1
References
- Photo Credit keyboard - error image by Kirubeshwaran from Fotolia.com