Our comments policy - We Follow

Can you reproduce the 404 error on your Wordpress blog at will?

November 26, 2008 · 0 comments

in General

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Can you reproduce an HTTP 404  error on your wordpress blog on demand? Try it. Chances are that if you have pretty permalinks enabled on your blog, wordpress will automatically match any URL begining with the URL-path you typed and redirect to an existing post instead of showing up a 404 error. For example http://www.advancedphotography.net/how redirects to http://www.advancedphotography.net/how-many-types-of-cameras-do-you-know/ (by the way AdvancedPhotography.Net is doin great;) ). Not bad. Except that the visitor is directed to an unintended page instead of being notified of the slip.

The 404 page is there for a purpose - and it should be used to notify the visitor about the page which could not be found. Here's a one-liner to fix this problem for you. Find your functions.php file in the current theme. Go to the Admin panel (Dashboard) > Design > Theme Editor > Seletct "Theme functions (functions.php)" at the far right to edit it. Add the following line right at the top after <?php

//kill cannonical redirects
remove_filter('template_redirect', 'redirect_canonical');

This shall take care of the problem and will ensure that visitors get to the 404 page when an incorrect URL-path on your blog is accessed.

Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It! Digg It!
    www.sajithmr.com

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: The Ultimate Cheatsheet and Checklist for a killer pillar blog post

Next post: Wordpress version 2.6.5 released