R – Multiple route parameters with clean URLs

asp.net-mvcrouting

I'm working a digg clone in ASP.NET MVC to help better teach myself ASP.NET MVC. I've been looking at how StackOverflow handles routing when passing in things like sorts and I guess I thought the whole point of using clean URLs is so you don't have things like ?sort=blah at the end of your URL for SEO.

Is there a recommended way of including many, possibly optional parameters into your URLs whilst still keeping them clean. I had a few ideas and I'd like to get some feedback.

Option 1:

Use wildcards (yuck)

Option 2:

Add the sorting to the beginning of the URL since it has the greatest coverage and ALWAYS applies when viewing stories. Exampke (using StackOverflow)

Instead of having ?sort=featured…

https://stackoverflow.com/featured/tagged/asp.net-mvc
https://stackoverflow.com/new/tagged/c#
https://stackoverflow.com/tagged/asp.net (some sort of default)

Anyway — I can't seem to think of any other ways of doing this.

Best Solution

Hang on, stack overflow does use query string parameters for sort, e.g.:

https://stackoverflow.com/questions/518812?sort=oldest#sort-top

/featured is different. In this case you are controlling what records are returned, not just how their sorted.

URLs describe resources. Query string parameters described how the resources are presented. In general:

  • Fragments which describe the nature of the data returned should be part of the URL.
  • Fragments which describe how that data is presented should be query string parameters.

Having query string parameters will not hurt your SEO.