The file /etc/hosts is only for mapping hostnames with IP addresses, not for URLs. There isn't any method that I'm aware which will allow you to do this across the board for all applications (that's built into a typical Linux distro), but you have a couple of options that will allow you to do it either per browser, via plugins, or using an HTTP proxy that filters all your requests from web browsers.
Plugins
2 such plugins for Firefox:
There are others. For Chrome:
I would probably go this route if it's just for yourself, or a couple of user's on a handful of systems.
Proxies
If it's for a larger domain of users then you'll need to use a HTTP proxy. Depending on which you choose, you may have to configure each user's browser independently.
If you choose to proxy all HTTP traffic using something like Squid, you can configure it as a transparent proxy, but this will have to be done on a system that's sitting in between your systems and the internet. Directions on how to set this up are discussed in this article, titled: Linux: Setup a transparent proxy with Squid in three easy steps.