views:

160

answers:

2

How do I allow users to map their domains to a url on my site? (like how tumblr or blogger does)

The app is being developed in Django. I want the users to be able to map their domains to mydomain.com/username (is this possible or do I need to have a format like username.mydomain.com?)

Also my app runs on a VPS so I have my nameservers as ns1.mydomain.com and ns2.mydomain.com.

+2  A: 

easiest way is through domain cloaking. most domain name providers will allow users this option.

another easy idea is to provide your users with a very generic html page that just includes their url on your site in an iframe and have them places that as their default directory index (e.g. index.html).

both the aforementioned would always show the base domain (without trickery). as noted below, a CNAME DNS record would take care of this, assuming they have the ability to edit DNS records...

www.someuserdomain.com.  CNAME username.yoursite.com
nategood
The users wouldn't need to use mod_rewrite, would they? Blogger simply instructs users to add a CNAME record for their domain name or sub domain that points to ghs.google.com, which is pretty simple and works much better than cloaking or iframes.
Dennis Palmer
yep i was in the middle of editing that as you posted . and you're correct, a CNAME record would be easier than an A record
nategood
Thats exactly what I'm looking for. Allowing users to add a cname record and then use the doimain for a url on my site. What do I need to setup on my side to get it working?
SingAlong
i believe to do it like domain.com/username you can use Apache VirtualHost with ServerName set to that user's custom domain (the left side of the CNAME record) and pointing DocumentRoot to the user's directory.
nategood
http://httpd.apache.org/docs/1.3/vhosts/examples.html should help you with that
nategood
A: 

In that case, you will have to consult your specific hosting setup for how to programmatically change your DNS settings. Whether you can actually do this depends on the host. If your server is running a DNS server that you have access to, you can probably change it that way.

Quartz