When your server can't find the requested page it will return a HTTP status code of 404. This tells the browser that the request has failed because the page you are asking for can not be found. When your server returns a 404 this needs to be handled so that your not just displaying the default browser page. Normally this will be done with htaccess by detecting a 404 error and redirecting the user to your own 404 page.
ErrorDocument 404 /404.html
If you use Wordpress then this 404 redirecting is already built into the core. When Wordpress can't find your page it will redirect the page to your Wordpress 404 page. To create a 404 page in Wordpress all you have to do is create a new file in the root of your theme and name it 404.php. Now that we have a page which will be displayed we need to customise this so that it's helpful to your visitors. It's good for the visitors to understand why they have got to this page, what this page means and what to do next. ## Default Wordpress 404
The default 404 page that comes with Wordpress will display your theme header, sidebar, footer and a page title.
<?php get_header(); ?> <div id="content" class="narrowcolumn"> <h2 class="center">Error 404 - Not Found</h2> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
This tells your visitor what has gone wrong and that the page is not found but it doesn't give them anything extra to do, where are they suppose to go from here? ## Add Useful Links
When the above 404 page is displayed the visitor is stuck with nothing to do but go back to your home page or click away from your site. The 404 page is a perfect place to add some useful links to help your visitors find what they are looking for. - Add links to your posts
To display a list of pages use the wp_list_pages() function.
wp_list_pages( 'title_li=' );
To display a list of categories use the wp_list_categories() function.
wp_list_categories( 'sort_column=name&title_li=' );
Use the wp_list_authors() function to display a list of all authors.
wp_list_authors( 'exclude_admin=0&optioncount=1' );
Display a list of archives by month by using the function wp_get_archives() with the parameter type=monthly.
wp_get_archives( 'type=monthly' );
To display the Wordpress search form use the function get_search_form(). This will search your theme folder for a file named searchform.php if it exists this function will return this file. If this file doesn't exist then it will return the default Wordpress form.
On my 404 file at Paulund I display the search form by using the get_search_form() function and then display a list of the archives by using the wp_get_archives( 'type=monthly' ); function. What do you do with your 404 page?