I am creating a `saas` application. Users have their own url like **user**.mysaasapp.com

To allow user to have own url, I use mod rewrite. Something like `http://mysaasapp.com/?user=user` to `user.mysaasapp.com` (This is working perfectly)

Now, I want to give user the flexibility to mask their url. This means that user can direct their subdomain (saas.theirdomain.com) to user.mysaasapp.com. How do i go about doing so. 

I read many articles(cname) on this but still have not have a definite solution. I am wondering how big companies like wordpress/google does that.

e.g <http://www.tumblr.com/docs/en/custom_domains>

e.g <http://developer.uservoice.com/docs/site/domain-aliasing/>

I realize that companies would take this process:

1. Get user to add cname
2. Get user to enter their domain in the saas app (maybe under custom domain)

What is needed from me the get this working? Thanks!