I own a website which gives every registered user a dedicated space like this: 
`www.mywebpage.com/user1
www.mywebpage.com/user2
www.mywebpage.com/user3`
Inside this path the user has his mini web site.

I'd like to give my users not a path within my domain, but a second level domain like this:
`user1.mywebpage.com
user2.mywebpage.com
user3.mywebpage.com`

A lot of websites do this, but I can't figure out how to get it!

1. Am I supposed to register a CNAME in my dns record for every single user? How the hell can I achieve this with PHP? I don't think it's possible to configure godaddy with a human-hand written script.
2. I may register an alias CNAME which points every second level domain to my top domain, and then check within my top domain the first token of the url retrieving the user: but now I can't redirect him on a new page (which is the index of his subsite) or I'd lost the web url userx.mywebpage.com.

How can I handle this? I'd appreciate any hint about the right path to follow in order to achieve my goal.