File sorta not found

Well, the site itself works just fine, but it looks like there were a few issues left to deal with.

First, Wordpress wasn’t returning the right status code (404) when a requested page couldn’t be found. That was easily fixed. Returning the correct HTTP status is not too important for human browsers but is a huge deal for search engines because when you’re indexing the Web you need to know which pages actually exist.

Well, the site itself works just fine, but it looks like there were a few issues left to deal with.

First, WordPress wasn’t returning the right status code (404) when a requested page couldn’t be found. That was easily fixed. Returning the correct HTTP status is not too important for human browsers but is a huge deal for search engines because when you’re indexing the Web you need to know which pages actually exist.

The status code was only part of the problem, though. See, what WordPress does when you use custom URL rewrites (as I do) is, if the requested URL doesn’t map to an existing file, the request is redirected to a custom error page. The annoying side effect is that as far as the server is concerned, a file was delivered correctly and no error is logged. Which messes up my stats. Fortunately, there’s a solution: a WP plugin called Redirection. It handles 30* redirections as well as keeping a log of 404 errors. The former isn’t necessary for now, since only gallery & photo URI’s have changed—and I have to use .htaccess to handle those, since they’re outside WordPress, but the latter is a godsend. Not a perfect solution, since in a perfect world I shouldn’t even have to use workarounds, but I’m very happy with it.

Oh, and AWStats (the stats package I’m using) was counting each browsed page twice. Seems a gallery page (.php, which is counted as a page view and not just a hit) is called in the background to build the photo grid displayed in the sidebar. Fortunately AWStats allows you to ignore certain pages, and this won’t be a problem in the future.