Search code examples
urlresthierarchyurl-design

Hierarchical vs. flat URL


I have a resource structure like flight > seat > reservation, so a reservation belongs to a certain seat which belongs to a certain flight:

http://example.com/jdf_3prGPS4/1/jMBDy46PbNc
                   ----------- - -----------
                        |      |       |
                        |      |       |
                     flight  seat  reservation

Since the customer gets this (somewhat ugly) URL for later cancellation I consider to leave out the resource structure and shorten the link to the reservation:

http://example.com/reservation/jMBDy46PbNc                     

Do you see any reasons (relevant to the user) not to shorten this URL?


Solution

  • The end user doesn't much care what the urls structure is. In fact given what they look like there they almost certainly don't even want to look at them and instead just clicky-click. This only really leaves functional considerations.

    If the URLs lead to exactly the same resource and that resource behaves exactly the same with the different urls then almost by definition it doesn't matter which one you use.

    I guess the only real factor might be whether there are any security implications. Would I be able to guess reservation IDs? Does that get me anywhere (ie would I still need to log in or something)? If there is a seat and flight as well they would have to be able to guess a valid combination of all three which is obviously a lot harder than just brute forcing the reservation ID.

    If this last is not a concern then I don't see any reason to ever use the longer url...