views:

157

answers:

3

The website we running let people register their own URL and redirect to our website to their user account. Lets it is something similar to Blogspot.com where users can have their own URL.

The problem is that in order to do this we need to have static IP address for the DNS redirection to work. We can easily get static IP addresses from most hosting companies, but if we change our hosting company it means we will have to force all our users to change their DNS setting to our new IP address. This if very problematic.

Is there a way of owning our own IP address that we can take it with us to wherever hosting company we decide to go with? Or there there other easier solutions out there?

+1  A: 

This is why domain names are usefull abstractions. The IP can change as long as the domain is registered to the new address. Do some research about Dynamic DNS. You'll like what you'll see.

http://www.dyndns.com/

Kyle J V
+7  A: 

This can be fixed using DNS. Create a single DNS "A" record that points "your-site.com" to your current IP address. Then when all of your users register their own URL, instead of having them set up "A" records, they need to set up a "CNAME" record that points to "your-site.com". If your IP changes in the future, you just have to change the "A" record for "your-site.com" and then all of the other DNS entries will automatically be updated.

David
I think this is the solution. Instead of creating A record, they need to create CNAME. Thanks David.
Cory
If all of your users are just creating subdomains, then use balexandre's answer.
David
+2  A: 

I would never create CNAMEs, that's kinda weird and not scalable (one more thing to do)...

just create a wildcard in your A record called *.yourdomain.com

the normal thing to do is create a new domain just for this, like *.yourdomainaccount.com and work the below example with that, plenty of known web services use this technique.

then in your default file or web.config or whatever file is your site configuration, create a simple method that get's the domain, for example the Server Variable SERVER_NAME

and then redirect the user to their own account.

in C#

string server = Request.ServerVariables["SERVER_NAME"];
if ( server.Contains("www.") || server.Contains("blog.") )
{
    // redirect the user to your main site or blog respectively
} 
else
{
    string user = server.Replace("http://","").split(".")[0];
    Response.Redirect(String.Format("www.domain.com/users/{0}", user));
}
balexandre
I am not sure if I understand this. If users enter theirOwnUrl.com into their web browser, how is that going to be redirected to username.myCompnayUrl.com if they don't change the CNAME or A record of their DNS. The URL is not registered with my site, it is registered with Godaddy or other registrant
Cory