Many domains, one database?
April 2, 2007 7:14 PM Subscribe
What would you say is the best way to have 10 domains access one database?
I am a web developer but my forté is definitely not the hosting or networking side. So, say I have 10 domain names along the lines of petcare.com, puppycare.com, kittencare.com, ferretcare.com, etc. I want each web site to display information about each of these different pets, but I want to store all the information in one database on the "master" petcare.com server.
Do I need to set up 10 hosting accounts to accomplish this? (I do already have the domain names.)
What I want to do is to visit puppycare.com and for it to go to one, "master" index.asp page which says, "ok, this time she typed in puppycare.com, therefore I'm going to retrieve all sorts of puppy-goodness from the database over at petcare.com." Or have it be able to say, "all righty, this time she wants ferrets." But just have *one* index.asp page process this, not 10 different home pages on 10 different web servers.
I am fully able to accomplish the above in a one-domain scenario by typing in "petcare.com/index.asp?pet=puppies," or what-have-you. But I'd like to just type in "puppycare.com" and have it get all the info from the database at petcare.com, and have it still display "puppycare.com/blahblah" in the address bar. How would *you* do this?
I needed to bounce this off someone (as I have no partners) to see what obvious answers I'm overlooking. My focus just isn't "there" in my web knowledge.
(Doubt this matters, but it has to be Access/.asp.)
I am a web developer but my forté is definitely not the hosting or networking side. So, say I have 10 domain names along the lines of petcare.com, puppycare.com, kittencare.com, ferretcare.com, etc. I want each web site to display information about each of these different pets, but I want to store all the information in one database on the "master" petcare.com server.
Do I need to set up 10 hosting accounts to accomplish this? (I do already have the domain names.)
What I want to do is to visit puppycare.com and for it to go to one, "master" index.asp page which says, "ok, this time she typed in puppycare.com, therefore I'm going to retrieve all sorts of puppy-goodness from the database over at petcare.com." Or have it be able to say, "all righty, this time she wants ferrets." But just have *one* index.asp page process this, not 10 different home pages on 10 different web servers.
I am fully able to accomplish the above in a one-domain scenario by typing in "petcare.com/index.asp?pet=puppies," or what-have-you. But I'd like to just type in "puppycare.com" and have it get all the info from the database at petcare.com, and have it still display "puppycare.com/blahblah" in the address bar. How would *you* do this?
I needed to bounce this off someone (as I have no partners) to see what obvious answers I'm overlooking. My focus just isn't "there" in my web knowledge.
(Doubt this matters, but it has to be Access/.asp.)
How many domains you can point to the same account depends on your hosting policies, but yeah, you can have lots of domains accessing the same script/folder and having the script do something different each time depending on the hostname accessing it.
posted by Firas at 7:34 PM on April 2, 2007
posted by Firas at 7:34 PM on April 2, 2007
I'm a little blurry on the details, but in Apache you would probably use 'name based virtual hosting', where one server hosts many sites, and serves up a different page based on how the client got there. That is, it doesn't matter if they go to puppycare.com or giraffecare.com. It goes to the same server. But the server replies with a different index.html for each name.
Another way would be to do the virtual hosting yourself; that is, all your domains go to the same place, and the same page gets served up every time, but you use some kind of fancy Javascript or something on the server side to massage the page before presenting it.
I'd tend to think the name-based hosting would be easier to manage. You may spend a little more time making changes that cross sites, as you'll have to change six or eight different homepages instead of just one. But by having them be standalone, a bug or problem with one shouldn't mess up the others.
Basically, this is very routine stuff, and it shouldn't be rocket science to get it going.
posted by Malor at 7:47 PM on April 2, 2007
Another way would be to do the virtual hosting yourself; that is, all your domains go to the same place, and the same page gets served up every time, but you use some kind of fancy Javascript or something on the server side to massage the page before presenting it.
I'd tend to think the name-based hosting would be easier to manage. You may spend a little more time making changes that cross sites, as you'll have to change six or eight different homepages instead of just one. But by having them be standalone, a bug or problem with one shouldn't mess up the others.
Basically, this is very routine stuff, and it shouldn't be rocket science to get it going.
posted by Malor at 7:47 PM on April 2, 2007
Drupal does this out of the box.
It's PHP though, not ASP.
posted by unixrat at 8:03 PM on April 2, 2007
It's PHP though, not ASP.
posted by unixrat at 8:03 PM on April 2, 2007
Yeah, I could've given you a lot more specific instructions for PHP & Apache… you might as well specificy the exact environment you're working with though. IIS most probably?
posted by Firas at 8:05 PM on April 2, 2007
posted by Firas at 8:05 PM on April 2, 2007
Try this search: You might have some luck with these results.
From an initial glance through the top results, you should find what you need. If you were using a non-MS stack I could help you with more specifics, but this is a bit out of my comfort zone.
posted by voidcontext at 8:22 PM on April 2, 2007
From an initial glance through the top results, you should find what you need. If you were using a non-MS stack I could help you with more specifics, but this is a bit out of my comfort zone.
posted by voidcontext at 8:22 PM on April 2, 2007
You don't even have to set up virtual hosting if you have a dedicated IP and program your app to check the host header before deciding what content to serve and what template to use to render it. This way, you can add a new site without having to fuss with your hosting arrangement.
posted by Good Brain at 8:49 PM on April 2, 2007
posted by Good Brain at 8:49 PM on April 2, 2007
Many ISPs let will happily let you attach as many domains as you like (for a nominal fee each) to a single account, using a single database. They'll even handle the Apache details. How you manage files on the back end is up to you. My ISP (pair.com) gives me a separate directory for each domain. A little Unix knowledge is all that's needed to share files.
posted by dws at 9:43 PM on April 2, 2007
posted by dws at 9:43 PM on April 2, 2007
Point all the domains at the same box, have the same index.asp load up. From there, grab the Request object, and ask it for what domain was called (look up the exact call). From there, you can do the correct database call and render the page you want. As for how to set this up with your hosting company, ask em.
posted by cschneid at 10:00 PM on April 2, 2007
posted by cschneid at 10:00 PM on April 2, 2007
Perhaps tangential, but... are you doing this to try to create inter-site linkage to boost Google rank or something? Since search engines can't be so easily gamed anymore, I'm not sure why else you'd want to do this.
I've had clients propose similar plans and I recommend instead that we create relevant topic sections on their main site (petcare.com/puppies, petcare.com/kittens) so whatever subject visitors had searched for, they'd end up being exposed to the client's main brand.
As others have explained, it's technically easy to accomplish what you asked for. But I'm not sure why one would want to manage, promote and track the usage of 10 domains when you can do one domain with 10 topics.
posted by Tubes at 11:57 PM on April 2, 2007
I've had clients propose similar plans and I recommend instead that we create relevant topic sections on their main site (petcare.com/puppies, petcare.com/kittens) so whatever subject visitors had searched for, they'd end up being exposed to the client's main brand.
As others have explained, it's technically easy to accomplish what you asked for. But I'm not sure why one would want to manage, promote and track the usage of 10 domains when you can do one domain with 10 topics.
posted by Tubes at 11:57 PM on April 2, 2007
I've done this several times in PHP. I point all the domains to the same directory, then use programming logic to determine which content is displayed (i.e. site1.com and site2.com have the same physical files, but they're handled differently via programming). Here's a simplified example of the code:
posted by Hankins at 12:08 AM on April 3, 2007
// 1. Figure out which site is being accessed
$site_host = str_replace("www.","",$_SERVER['HTTP_HOST']);
// 2. Set the sql pull based on the site being accessed
if ($site_host == "puppycare.com")
$sql_pull = "puppies";
elseif ($site_host == "ferretcare.com")
$sql_pull = "ferrets";
// 3. Make the sql call
$sql = "SELECT * FROM table WHERE animal = '$sql_pull'";
posted by Hankins at 12:08 AM on April 3, 2007
An approach I've taken is to pay for a single host account with a fixed IP address. This cheapie hosting site has it as a $30/yr add-on. I assume others do too.
Then register all of your domain names with a registrar who'll let you edit the DNS records. Set the A records for the domain names you want to use to your fixed IP.
* 123.456.789.10
@ 123.456.789.10
On your hosted server you have an .htaccess file that parses those domain names:
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(puppies\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(kitties\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(gerbils\.com) [NC]
#RewriteRule ^index.php?section=%1&animal=%2 [L]
(This example also handles subdomains)
When a user requests "http://recipes.kitties.com," that will stay in their address line but the actual page that gets served up comes from
index.php?section=recipes&animal=kitties.com
HTH!
posted by nonmyopicdave at 7:22 AM on April 3, 2007
Then register all of your domain names with a registrar who'll let you edit the DNS records. Set the A records for the domain names you want to use to your fixed IP.
* 123.456.789.10
@ 123.456.789.10
On your hosted server you have an .htaccess file that parses those domain names:
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(puppies\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(kitties\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.(gerbils\.com) [NC]
#RewriteRule ^index.php?section=%1&animal=%2 [L]
(This example also handles subdomains)
When a user requests "http://recipes.kitties.com," that will stay in their address line but the actual page that gets served up comes from
index.php?section=recipes&animal=kitties.com
HTH!
posted by nonmyopicdave at 7:22 AM on April 3, 2007
Response by poster: Thanks all -- I think I've probably gathered all the info I need. At least now I know it's possible. :)
Tubes: has nothing to do with google rankings. It's more of a branding thing. (This isn't really a pet care project.) We want it to appear more like there are 10 different businesses, and most especially, we want to use 10 recognizable domain names. (Like, rather than computers.com/harddrives, we'd prefer harddrives.com, right? -- easier to remember; more recognizable.)
posted by iguanapolitico at 7:37 AM on April 3, 2007
Tubes: has nothing to do with google rankings. It's more of a branding thing. (This isn't really a pet care project.) We want it to appear more like there are 10 different businesses, and most especially, we want to use 10 recognizable domain names. (Like, rather than computers.com/harddrives, we'd prefer harddrives.com, right? -- easier to remember; more recognizable.)
posted by iguanapolitico at 7:37 AM on April 3, 2007
create your site as a template and then populate them all from a single database.
posted by browolf at 10:52 AM on October 21, 2007
posted by browolf at 10:52 AM on October 21, 2007
« Older Looking for a specific children's book | Tips for studying (CA Bar) at Santa Clara U Law Newer »
This thread is closed to new comments.
posted by fvox13 at 7:29 PM on April 2, 2007