How does the sub-domain like urls are created in web apps?

Hello,      I registered in a site called basecamp. After I registered, they gave me a url like where i have to log in access my project management. I heard that basecamp is built in ruby on rails. I couldn't get the point of building a subdomain like url. Can anyone give some guidance of how to create a sub domain like url using rails? Thanks in advance

You can use subdomains for various purposes. One is to host different servers (eg and, or to host different applications (eg and

I believe Basecamp use it to have nicer URLs. The standard way would be: //, or //

// looks nicer.

A few links: