How do I Remove Server Information From Apache Error Pages?
Website owners whose host use the Apache server may not wish to use the default error pages, which contain information about the Web server, but very little useful information to visitors. If you create a custom error page and edit your HTAccess file, you can direct your visitors there. This page does not have to show server information like Apache error pages. You can include features such as a link to contact you or a box to search your website for relevant pages.
Instructions
-
Create Error Page
-
1
Open your text editor, such as Notepad or TextPad, and create a new document from the File menu.
-
2
Type the HTML code to create a custom error page. A sample page may contain code like the following.
<html><head><title> 404: Page Not Found</title</head>
<body><h1>404: Not Found</h1>
<p>You have typed an address or followed a link to a page that does not exist. Please check the address and try again. If you feel you have reached this page in error, please <a href="mailto:you@domain.com">contact me</a>.</p>
</body></head>
-
-
3
Add additional elements, such as a link to your website's index, or a search form by typing the appropriate code. For example, a link to your website's main page might appear similar to the following, where "http://domain.com" is a stand in for your actual URL.
<a href="http://domain.com">Return to the main page</a>
-
4
Click to open the File menu and choose "Save As". Type a Web page URL followed by ".html." You can simply name a 404 error page "404.html."
Create Htaccess
-
5
Open your text editor and click to open the File menu. Select "New" file.
-
6
Type the code that will instruct your Apache server to display your custom error page. For example, if you want only a custom 404 page, you may type "ErrorDocument 404 /404.html".
You can specific multiple error pages using the same format:
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /402.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
-
7
Choose "Save As" from the File menu and type "text.htaccess" into the save box. You must select "All Files" from the file type menu.
Upload the Files
-
8
Connect to your website via browser control panel or FTP. If using FTP, launch your program and enter your username, password and FTP host into the appropriate fields. Press "Enter" to connect.
-
9
Navigate to your base directory in the right (remote server) pane in your FTP program.
-
10
Navigate to the folder on your computer that contains the error and HTAccess files.
-
11
Double click or right click the files and select "Upload" to upload them to your host server.
-
12
Right click on "text.htaccess" in the Remote pane and choose the option to rename your file. Type ".htaccess" and click "Enter" on your keyboard. If your FTP client does not show hidden files, such as those with the htaccess extension, it may disappear.
-
1
Tips & Warnings
You may specify as many custom error pages are there are error standards.
"404" is the error code for a page that does not exist while "403" errors indicate restricted access and the server will display a "500" error when it experiences difficulties processing an activity such as running a script.
If using a browser-based control panel to upload files, launch your browser and enter the URL to your control panel in the address bar. After logging in, click the link or icon to access the File Manager. Select the option to upload a file and rename the HTAccess file.
Some control panels allow you to edit error page URLs without creating or editing the HTAccess.
References
- Photo Credit error image by dead_account from Fotolia.com