Search code examples
urlusabilityurlhacks

How would you design a hackable url


Imagine you had a group of product categories organized in a nice tree hierarchy and you wanted to provide hackable urls to browse these. You could do something like this

/catalog/categorya/categoryb/categoryc

You could then quite easily figure out which category you should list the products for (note that the full URL is needed since you could have categories with the same name but at different locations in the hierarchy)

Now what would be a good approach to add product information in that as well? To give you an example, you wanted to display the product Oblivion for this category

/catalog/games/consoles/playstation/adventure

It's tempting to just add the product at the end of the url

/catalog/games/consoles/playstation/adventure/oblivion

but the moment you do so you loose the ability to know if its category or a product which is called oblivion. I personally feel that not being forced to add a suffix such as .html

/catalog/games/consoles/playstation/adventure/oblivion.html

would be the nicest solution and using some sort of prefix, such as

/catalog/games/consoles/playstation/adventure/product:oblivion

You could also add some sort of trigger like

/catalog/games/consoles/playstation/adventure/PRODUCT/oblivion

not as nice either and you would (even though its very unlikely it would be a problem) restrict yourself from having a category called product

So far a suffix solution looks like the most user-friendly approach that I can think of from the top of my head but I'm not fond of having to use an extension

What are your thoughts on this?


Solution

  • Deep paths irk me. They're hideous to share.

    
    /product/1234/oblivion --> direct page
    /product/oblivion --> /product/1234/oblivion if oblivion is a unique product, 
                      --> ~ Diambiguation page if oblivion is not a unqiue product. 
    
    /product/1234/notoblivion -> /product/1234/oblivion
    
    /categories/79/adventure -->  playstation adventure games
    /categories/75/games -->  console games page
    /categories/76/games -->  playstation games page 
    /categories/games --> Disambiguation Page. 
    

    Otherwise, the long urls, while seeming hackable, require you to get all node elements right to hack it.

    Take php.net

    php.net/str_replace -->  goes to 
      http://nz2.php.net/manual/en/function.str-replace.php
    

    And this model is so hackable people use it all the time blindly.

    Note: The .html suffix is regarded by the W3C as functionally meaningless and redundant, and should be avoided in URLs.

    http://www.w3.org/Provider/Style/URI