These aren't really physical directories on the system. They're dynamic names within the URL name space that get mapped to either a physical directory or are interpreted as an argument to a function or application which then acts on it.
It's typically URL rewriting that's facilitating this "magic". Take a look at this tutorial from smashingmagazine if you're really curious, titled: Introduction To URL Rewriting.
Example
Say you're wikipedia. The entire site is primarily PHP based so the real URLs are something like this:
http://en.wikipedia.org/w/index.php?title=Barack_obama
http://en.wikipedia.org/w/index.php?title=Barack_obama But when you're at the site you're likely to see the page like this:
http://en.wikipedia.org/wiki/Barack_obama
http://en.wikipedia.org/wiki/Barack_obama The Apache configuration that makes this happen:
RewriteEngine On #Look for the word "wiki" followed by a slash, and then the article title RewriteRule ^wiki/(.+)$ w/index.php?title=$1 [L] This takes the URL that the browser is accessing "http://en.wikipedia.org/wiki/Barack_obama" and rewrites it internal to the web server (Apache) to this, "http://en.wikipedia.org/w/index.php?title=Barack_obama".
I often think of this as similar to on Star Trek where they had the universal translator. The server is taking one set of URLs on the input (from the browser) and on the backside is translating those URLs into other ones which map to actual applications and scripts on the server or even other servers.