It's something the web server does - and it's damn awesome what you can do with it.
Have a read up on URL rewriting in the Apache URL rewriting guide.
http://httpd.apache.org/docs/2.2/misc/rewriteguide.html
IIS can also do URL rewriting but you have to pay for a plugin.