Jump to content

Vanity Urls


ozrhod

Recommended Posts

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 by ozrhod
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by kicken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.