TextThing URLs and 404s

Published 1 December 04 by Justin French, 9 comments

As discussed earlier, the aims for TextThing were to have nested “categories” (eg /recipes/savoury/main-meals/) into which an article could be posted.

I can tell you that I’ve got ‘unlimited’ nested categories working beautifully, and it should be nice and fast for any reasonable number of ‘directories’ (at this early stage, each directory is a separate query to the database, so an 18-level path would of course mean 18 queries to the database!).

It’s using a version of this article’s hierarchical data model, with a bunch of modifications to make things far more extensible.

It would appear at this early stage that I’ve solved something very few CMSs have bothered to solve, and something I’ve always wanted – hooray!

Now, this is the bit where I need your help – I need to decide what to do with 404 (not found) articles or categories.

Let’s consider the following URI: /recipes/savoury/soups/sweet-potato-soup/. We walk up the path one chunk at a time, and match it against a category in the database. In the above URI, we’d match /recipes/savoury/soups/ to nested categories, then assume we have the article title sweet-potato-soup left over.

We’d then have a look in the articles for a title which matches the the soups category, and display it. Easy.

But what do we do when the article is not found? What do we do when we only make it half way up the tree before stopping? The convention is to redirect to a 404 (not found) page explaining that the requested URI could not be found, but I’m thinking we can do more than that…

Why not walk as far up the path as we can (eg /recipes/savoury/) and show the contents of the category at that point? With any luck, the user can then click their way through to the right URL. This is quite similar to Apache’s Multiviews directive (which works backwards until it can find a valid resource), and much nicer than a 404 page, right?

To make things less confusing for the user, we could show a message like “sorry, couldn’t find the exact URL you were after, but here’s the best we could do” and maybe change the URL in the browser’s address bar with a redirect to reflect the new location.

So, my question to you, is which would you prefer? A definitive “nope, can’t find it” attitude, or something more dynamic like “couldn’t find it, but this might be a good place to start”?

Please share your ideas and opinions in the comments.

Options

What is this?

portrait of Justin

This is the online home of Justin French, a designer & web application developer located in Melbourne, Australia. I like finding ways to make things work better. I like clarifying and simplifying. I like to understand how you understand things.

» read more

Subscribe to my feed

Follow me on Twitter

@justinfrench

More Notebook Articles

Show more notebook articles

Search