How to change the site’s default 404 Error not found page
The apache’s default “404 Error not found” page seems ugly. And may some hosting service put theire ads in it. We can add some entry in .htaccess to change the defualt 404 error page. This method can also be used for some other error codes. A list of the server returned codes can be found in Table 1.
It simply need to add the “ErrorDocument” command to the .htaccess file. The format is:
ErrorDocument code /dir/file.ext
or
ErrorDocument code http://mydomain.name/dir/file.ext
For example:
ErrorDocument 404 /404.html
would cause any error code resulting in 404 to be forwarded to mydomain.name/404.html
ErrorDocument 404 http://pkill.info/404.html
would cause any error code resulting in 404 to be forwarded to http://pkill.info/404.html
For other error code such as 401 the method is the same. But not all the returned code should be forwarded. Most of the time, forwarding the error codes is enough.
Table1: Server returned codes
| Successful Client Requests | |
| 200 | OK |
| 201 | Created |
| 202 | Accepted |
| 203 | Non-Authorative Information |
| 204 | No Content |
| 205 | Reset Content |
| 206 | Partial Content |
| Client Request Redirected | |
| 300 | Multiple Choices |
| 301 | Moved Permanently |
| 302 | Moved Temporarily |
| 303 | See Other |
| 304 | Not Modified |
| 305 | Use Proxy |
| Client Request Errors | |
| 400 | Bad Request |
| 401 | Authorization Required |
| 402 | Payment Required (not used yet) |
| 403 | Forbidden |
| 404 | Not Found |
| 405 | Method Not Allowed |
| 406 | Not Acceptable (encoding) |
| 407 | Proxy Authentication Required |
| 408 | Request Timed Out |
| 409 | Conflicting Request |
| 410 | Gone |
| 411 | Content Length Required |
| 412 | Precondition Failed |
| 413 | Request Entity Too Long |
| 414 | Request URI Too Long |
| 415 | Unsupported Media Type |
| Server Errors | |
| 500 | Internal Server Error |
| 501 | Not Implemented |
| 502 | Bad Gateway |
| 503 | Service Unavailable |
| 504 | Gateway Timeout |
| 505 | HTTP Version Not Supported |
Read more:
- Speeding up the site by using PHP GZIP compression
- Friendly WordPress navigation using page numbers instead of next and previous links
- Change WordPress’s excerpt length
- How to redirect WordPress feed to feedburner using .htaccess
- Get the number of all posts in WordPress
- How to redirect old domain to new domain using htaccess redirect


















Leave your response!