How can other people map their domain names to my subdomains?
November 20, 2004 1:19 PM   Subscribe

How do you do that thing whereby a person can go to your website and map their domain to a subdirectory of your own website? Do you need to have root on your server to do this or are there easier (read: cheaper) ways to do it?
posted by subverted to Computers & Internet (11 answers total)
 
if you get a reseller account with a hosting company you should have this capability included, typically handled in a rather simple fashion using control panels.

i pay $60-80 something a year for a gig of space, unlimited domain hosting and 10 gigs bandwidth (or something like that). you should be able to find similar deals. this is gonna be *way* cheaper than getting a dedicated server.

make sure you find a web host that isn't going to go out of business in two months though.
posted by fishfucker at 1:40 PM on November 20, 2004


oh. whoa. it just occured to me that you'd like this to be an wholly automated process?

i'm not exactly sure how they'd do that.

they'd need to make some nameserver changes with their registrar, that's for sure.
posted by fishfucker at 1:47 PM on November 20, 2004


Just get a host that allows this. Most of them will do it for a fee. Note: I assume you're talking about allowing people to have friendsname.yourdomain.com. Is that right?

Dreamhost does this. I forget their rates. It ain't automated though. You'll have to set up each one.
posted by dobbs at 2:04 PM on November 20, 2004


Response by poster: I have a reseller account and run many doamains. I'd like people (i.e. future clients) to be able to run a service I will provide in the future from my own server but have the customer's URL map to my server. A lot like how Typepad do it, I guess. And yes, it all has to be automated. Does this make sense?
posted by subverted at 2:29 PM on November 20, 2004


yeah. 'fraid that the customer is going to need to make registrar changes in order for that to work. if *you* register the name for them, there should be some kind of script you can run that will enter in the proper nameservers for this to happen. some of the control panels *may* have this feature. I'd talk to your host and see what they can do (if they actually respond to your emails.)

basically, you want an auto-signup script for your reselling.
posted by fishfucker at 2:50 PM on November 20, 2004


This is pretty easy actually. In your DNS you can set up a wildcard entry, ie:

*.whooziwhatsit.com -> ###.###.###.###

That will match any subdomain -- then it's just a matter of setting up some sort of server side process (could be scripted, could be mod_rewrite) to translate the hostname into a path and deliver the proper files.

You'll also need to make sure your host supports this. If you've got a static, non-shared IP it shouldn't be a problem.

(Matt does this -- check out how you can go to matt.rules.metafilter.com, or asdfjaidsfj.metafilter.com or anything else.metafilter.com)
posted by treebjen at 4:06 PM on November 20, 2004


oh. you wanted subdomain redirects.

yeah. sorry. i was totally confused there.
posted by fishfucker at 5:37 PM on November 20, 2004


I do this with my web hosting company, and as treebjen says, it's the combination of a wildcard in your DNS and mod_rewrite.

The mod_rewrite looks like this:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/cgi-bin.+$
RewriteCond %{HTTP_HOST} [^.]+\.ierna\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ([^.]+)\.ierna\.com(.*) /$1$2
RewriteCond %{HTTP_HOST} ^ierna\.com
RewriteRule ^(.*)$ http://www.ierna.com$1 [R=permanent,L]

What this does, roughly, is take everything but cgi-bin requests (because I only wanted a single cgi-bin per domain, and that's not on a subdomain) and rip the subdomain off and place it at the end of the domain as a subdir. Then it adds the rest of the URI after the new directory. The last RewriteCond/Rule is to take the raw domain and bounce it to the www subdomain.

So, if you went to blah.ierna.com, and I had a corresponding directory called "blah" inside my webroot, you would get that content.
posted by tomierna at 2:35 PM on November 21, 2004


mod_rewrite... that's Apache, right? Is there an equivalent process for IIS?
posted by Tubes at 6:53 PM on November 21, 2004


I believe IIS's equivalent is called ISAPI_rewrite.
posted by lpqboy at 10:50 AM on November 22, 2004


Just came back to check up on this one. Thanks, lpqboy! I had no idea that existed.
posted by Tubes at 10:28 PM on November 30, 2004


« Older Leaning Tree   |   Reliable Web Hosting Newer »
This thread is closed to new comments.