5

I have a website where factories are stored in different categories, but now i was wondering how to call the factories in my urls.

I have an url for showing factories in a category:

http://mydomain.com/factories

I also have a page where all my factories from the database are displayed i don't know how to call that url. the url can not be the same so i need something that works for everybody.

i tried something like:

http://mydomain.com/allfactories

but i think it looks stupid.

Could someone help me out with this?

0

3 Answers 3

11

A quite common pattern for showing all of something is to extend the category with a filter, which in your case would be something like:

http://mydomain.com/factories/all

That way you can use the filter in your URL to select factories in let's say Europe:

http://mydomain.com/factories/europe

And moving down the list to a single factory, such as:

http://mydomain.com/factories/my-industry

You'll have a flat structure on your filter and need only to implement your taxonomy on each factory correct.

0
2

Even though this presentation is about REST, it talks a lot about URLs, (from 16min to 25min approx) and might interest you.

Main points that gets out of the presentation is that the URL should represent a ressource, and filters of these ressources should go in the query string. The query string is meant to be specific to the query, and filters are a direct fit for this category.

In your case, I would go with something like

http://mydomain.com/factories -- to retrieve all factories
http://mydomain.com/factories/{id} -- to retrieve a specific one

http://mydomain.com/factories?category={cat} -- to filter a category.

The reasoning behind that is that if tomorrow you want to add more filters, what will you do? Just add more slashes?

And get to something along :

http://mydomain.com/factories/myCategory/united-states/blep/bloop -- ???
http://mydomain.com/factories/myCategory/blep/bloop -- Oh wait now, is blep a country? This is not clear

This is pushed to the extreme, but it shows something that can become very problematic, because some parameters will become obligatory as you add more possibilities.
The parameters in the URL become ambiguous; we can not know which parameter is which if they are not all there and in order. But if I need to put all parameters, then the default one get in the URL and everything gets cluttered.

1
  • 1
    @Kees It might seem long (1hour), but it's a very good presentation and it is very well done. It's made by David Zülke a guy who works for Symfony Framework Commented Apr 17, 2013 at 14:45
1

Since there are multiple categories, I would suggest using http://mydomain.com/factories/category-X, and http://mydomain.com/factories/all

1
  • yeah i think /factories/all looks nice. but i want to keep the urls as clean and short as possible. so i think this is the best way. Commented Apr 17, 2013 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.