We have two pages. One is a landing page, given by the route /region
. The other is a detail page for a particular region, given by the route /region/summary/{id}
. The landing page is the normal way by which a user would navigate to a detail page.
Suppose a user visits the intermediate route region/summary
. Should he be redirected to a 404 page, since technically it's not a valid route, or redirected to the region
page, since the main problem is that he didn't provide an id in the route, and he'd find valid links everywhere on the landing page?
Answer
This was originally a comment, because I had assumed it was considered and not used prior to this question being posted..
At the moment, these are your URLs (with "summary" being a type of action, presumably):
/region
/region/{action}/{id}
Your question is, what should you do if someone tries to access it without an ID, like this:
/region/{action}
I say: Don't allow it in the first place, and shape your URLs conceptually like this:
/region
/region/{action}
/{region}
/{region}/{action}
So with this mapping: {region} -> region/{id}
, you get the URLs:
/region
/region/{action}
/region/{id}
/region/{id}/{action}
/region
would still go to the same place you intend; a landing page./region/{id}/summary
does the same thing as your/region/summary/{id}
/region/{id}
basically would mean "Get me information about Region {ID}", which could either 302 to/region/{id}/summary
, or just return that page.- Likewise for
/region/summary
- the user is asking for information about the landing page. It should return the same thing as/region
(or 302 to it, or/region
should 302 to here).
RESTful URLs like this are used in web APIs, and they're pretty intuitive, making it a good model for sites that can use them.
Two more sets of examples from the StackExchange API (which, granted, doesn't include /tags/{tags}
):
/badges Get all badges on the site, in alphabetical order.
/badges/{ids} Get the badges identified by ids.
/badges/recipients Get badges recently awarded on the site.
/badges/{ids}/recipients Get the recent recipients of the given badges.
/tags Get the tags on the site.
/tags/{tags}/info Get tags on the site by their names.
/tags/synonyms Get all the tag synonyms on the site.
/tags/{tags}/synonyms Get the synonyms for a specific set of tags.
And one from this Edit Answer page (which, unfortunately, doesn't work without /edit
...):
http://ux.stackexchange.com/posts/39273/edit
No comments:
Post a Comment