URL naming conventions
Posted
by LookitsPuck
on Stack Overflow
See other posts from Stack Overflow
or by LookitsPuck
Published on 2010-06-10T16:31:56Z
Indexed on
2010/06/10
16:32 UTC
Read the original article
Hit count: 303
So, this may be a can of worms. But I'm curious what your practices are?
For example, let's say your website consists of the following needs (very basic):
- A landing page
- An information page for an event (static)
- A listing of places for that event (dynamic)
- An information page for each place
With that said, how would you design your URLs?
Typically, I'd do something like the following:
www.domain.com/ - landing page [also accessible via www.domain.com/home] www.domain.com/event - event information page www.domain.com/places - listing of all places www.domain.com/places/{id} - place information page
Now, here's a question. Just grammatically speaking, I have a hangup of referring to a given place in a url as being plural. Shouldn't it make more sense to go with this:
www.domain.com/place/{id} as opposed to www.domain.com/places/{id}
In some frameworks, you have a convention to follow (for example, ASP.NET MVC) by default. Yes, you can define custom routes to have /place/{id} route to the PlacesController. However, I'm just trying to keep this a bit abstract in discussion.
With that being said, let's see for instance on another page of your site, you have a link, that when clicked, would open a modal popup populated with place information. Where you place that information?
We could go with something like this:
www.domain.com/ajax/places/{id} OR www.domain.com/places/{id} and serve based on the request header (that is, if requesting JSON, return JSON?}.
Finally, for SEO reasons, typically I use a slug associated with a given resource. So, something like such:
www.domain.com/ajax/places/{id}/london
Where london is only there to add decoration to the link for SEO reasons. Is this sound?
I ask all of these questions, because these are practices that I've been using for awhile, and I'd just like to see what other developers are doing or if I'm approaching things incorrectly.
Thanks!
© Stack Overflow or respective owner