Web Development for 2010

Alexander Dickson - Web Developer covering PHP, jQuery / Javascript, XHTML, CSS, more

Best practices for formatting a URL with a numerical index

Filed under General. Published on Monday, 3rd August 2009.

A lot of the time, using pure clean URLs are impossible due to certain limitations such as the possibility of the segment mapping to more than one resource. In this case, the URL must contain an ID (generally the ID in the database).

Whilst this certainly does not look as pretty, it doesn't mean you can't have a slug in the URL for readability and for SEO purposes.

Consider this URL: http://stackoverflow.com/questions/361635/debugging-javascript-in-ie7

The portion /debugging-javascript-in-ie7 should be entirely optional, because user generated content does change, and some URLs can be accidentally truncated as they are copy and pasted, for example. In the example above, the slug is optional.

The slug, being optional, should be added if the resource is requested without the slug. This will ensure the correct URL is copied / linked to and it will ensure you won't be penalised for duplicate content. This is trivial using either .htaccess (or equivalent) or in the server side code.

Comments

  • Alexander Dickson

    Posted on Wednesday, 19th August 2009 @ 9:54am.

    WOOF

  • courtnee

    Posted on Friday, 14th August 2009 @ 7:51pm.

    MEOW

Leave a Comment

Comment Details

Your email will never be displayed. If you have a gravatar, it will be displayed.

Note: Your comment may require approval before it is posted to the site.

Stack Overflow Profile

view full profile »

About

I'm a web developer from the Sunshine Coast, Australia. more »