I'm trying to produce a whitelabel service for my website. I wish to get it done like dohop does. And so i produced a sub domain on my small primary site like : whitelabel.example.com and i wish to understand what i must do for a user to have the ability to set a cname on his domain to make use of my service.

I attempted this:

User's domain: userdomain.com
tests.userdomain.com - CNAME - whitelabel.example.com
www.tests.userdomain.com - CNAME - whitelabel.example.com

After i ping tests.userdomain.com i recieve:

Pinging to whitelabel.example.com

And so i guess the CNAME does it's job however i can't evaluate which i must do on my small server (example.com) to be able to understand and answer the request. All i recieve after i type tests.userdomain.com during my browser is cpanel's default page that notifies me of the error.

Help anybody?

Should you was using PHP for example you could do this:

    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
    $host = str_replace('.example.com','',$host);
    echo $host;