EDIT: found a good approach at: http://stackoverflow.com/questions/1180/how-to-make-subdomai...
Parse that to get the first part of it like in the example.
EDIT: found a good approach at: http://stackoverflow.com/questions/1180/how-to-make-subdomai...