Error 404 — Not Found

25Dec05

Since migrating to WordPress I’ve had some nagging 404 problems. I managed to import my permalinks into WordPress, and crafted some .htaccess rules to handle the major structural differences with categories and RSS feeds, but I completely forgot that there was a 404 script handling certain aspects of my last content upheaval.

The script had been pretty simple — run some permutations of the requested URI, check the filesystem to see if any exist, and if so, re-direct to the correct location.

With WordPress there is no filesystem to check.

I wasted hours tracing the request path through the WordPress code and Googling for other people’s 404 solutions. Then I just happened to open wp-includes/functions.php and there is was: function url_to_postid($url). Pass in a fully-qualified URL, get back 0 if there are no posts that match.

So my fancy 404 re-director is working properly once again. Hopefully the next time that I check my errors logs all I will see, once the spam bots are filtered out, are a handful of requests for content that is truly gone.

And I post this hoping that Google will save the next person needing to validate that a URL exists in WordPress from wasting as much time as I did trying to find url_to_postid.


Valid XHTML 1.0 Transitional

Advertisements

Plugging my Employer

 


Plugging my Employer

Advertisements

Flickr Photos