ozrhod Posted November 11, 2012 Share Posted November 11, 2012 (edited) Hi guys and gals, I'm curious how webs.com and tumblr.com and even blogger.com make the custom domain thing work (not after vanity URLs like facbook.com/username but username.com displaying facebook.com/username and redirecting facebook.com/username if you try to visit it - like tumblr does). Now from my research I know the user has to change the A Name and CNAME records of the domain, but I'm not sure how they do it server-side (their side). Obviouslly you complete a form saying which domain you want to use and their servers then do something to this - but what? And why is the CNAME or A record IP different from the normal sites CNAME or A record IPs? What is with this? Hope someone can shed some light on this. ozRhod (PS - realised I posted in wrong spot [maybe] - feel free to move) Edited November 11, 2012 by ozrhod Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/ Share on other sites More sharing options...
ozrhod Posted November 13, 2012 Author Share Posted November 13, 2012 Some ideas please? Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/#findComment-1392012 Share on other sites More sharing options...
thara Posted November 13, 2012 Share Posted November 13, 2012 what do you need to do? what is your problem? Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/#findComment-1392015 Share on other sites More sharing options...
AyKay47 Posted November 13, 2012 Share Posted November 13, 2012 I believe wildcard subdomains is what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/#findComment-1392038 Share on other sites More sharing options...
ozrhod Posted November 17, 2012 Author Share Posted November 17, 2012 what do you need to do? what is your problem? WIth Tumblr and Google Blogger I can change my URL from say http://tumblr.com/ozrhod or http://ozrhod.tumblr.com to www.ozrhod.com Now I know I have to get the users to make changes to the A and CNAME records of the domain (e.g., www.ozrhod.com) but to what A and CNAME records? Tumblr and Google blogger dont seem to use the same ones as their main site - why? And how do I make it all work? Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/#findComment-1393146 Share on other sites More sharing options...
kicken Posted November 17, 2012 Share Posted November 17, 2012 (edited) Now I know I have to get the users to make changes to the A and CNAME records of the domain (e.g., www.ozrhod.com) but to what A and CNAME records? You would have some IP address (or list of addresses) that the user would have to setup their domain to point to. As an alternative, you could host their DNS for them so that you don't have to get them to setup all the CNAME/A records but instead just change the domain's NAMESERVER settings to point to yours. For example if you were running your setup on IP 10.0.1.1 (hostname sitesrv.example.com), you would have the user configure their DNS so that their A records for their domain point to IP 10.0.1.1 (or their CNAME records point to sitesrv.example.com). As for why places use a different set if IP's for their customer sites vs their own is due to keeping things separate. You wouldn't want a problem with a customers site causing issues with your own site, so you keep them as separate entities, likely on completely separate servers. If you're hosting lost of customers, you'll likely need to divide up the customers as well among several different machines/addresses, but there are a variety of ways to do that And how do I make it all work? In the application code, when a request is received you would examine the Host: header ($_SERVER['HTTP_HOST'] in php) to determine which domain the request was sent to. With the domain name you can lookup in your database which user that domain name belongs. For the first case (http://example.com/username) you would examine the URI that was requested ($_SERVER['REQUEST_URI'] in php) to get the username. For example: if HTTP_HOST == 'example.com' then set username=REQUEST_URI else if HTTP_HOST == '*.example.com' then set username= HTTP_HOST - '.example.com' //username is the hostname, minus the .example.com part else { set username = result of database query where domain=HTTP_HOST } Once you have the appropriate user, you can display that user's content. If you're unable to find a user for the request, you could either display an error page, or just redirect the request to your homepage. Edited November 17, 2012 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/270557-vanity-urls/#findComment-1393153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.