tags:

views:

47

answers:

2

I need to direct multiple domains to a single set of (PHP) files. So I point a domain at my server, which then goes to a single index.php file. This index.php file then detects the domain accessing it and returns the appropriate content. I do not want to add domains or set-up sites manually though as this is for a content management service. So it should be a case of a user signing up and it immediately works without me having to manually do anything. The file set must also exist only once, so updates can easily be applied to everyone.

I am currently on shared hosting, but I believe I may need to move to a VPS (running Apache) to achieve this.

How do I go about doing this?

Thanks

A: 

"So it should be a case of a user signing up and it immediately works without me having to manually do anything"... So you want magic. Anyways domains point to a directory so that is easy just point all domains to the same directory. PHP can examine the full URL so you can use that to select the content. If you are using something like Joomla you might be able to customize the starting extension. For example all joomla content is stored in tables named jos_XXX. It should theoretically be modifyable to the base table is domain_com_XXX Maybe, but you really need to find a good programmer for this, I don't know of any systems that will do this out of the box. Maybe someone else might know of one.

MindStalker
+1  A: 

Unless I'm missing something about what you're trying to do, a simple CNAME DNS record may work. Just CNAME the new domain to your existing 'main' domain.

However, if you need to know what domain was requested using shared hosting this very well may not work. The catch is you would also have to setup the hosting account to accept requests from the new domain. This seems to be what you're trying to avoid.

If this is the case, you'll need a static IP, and Apache setup to accept wildcard domains and pass them to your application (index.php in this case). You may not need a VPS for this, just a relatively configurable shared hosting account.

Update: To get this working on shared hosting, check out the Apache VirtualHost directive. That's what Apache uses to setup a (wait for it) 'virtual' web server (document root, logs, etc) allowing a single server to host multiple sites. Also checkout Named Based Virtual Hosting, you'll need an account that doesn't do virtual hosting that way.

Tim Lytle
Oh, I didn't realise there was a server-specific equivalent of stackoverflow! I'll ask on there too if I can't find an answer here.Yes, I am trying to avoid having to setup separate accounts on my reseller hosting. It's not so much the account creation (there's an API for that) but that I'd have to manually upload and install the site files each time.Do you have any links on how to setup Apache for wildcard domains? I can only find ones for subdomains at the moment.
Fourjays
I should probably rephrase that, I'm more of a programmer than a sysadmin - Apache doesn't need to be configured for a specific domain, in can just respond to any incoming HTTP request. Of course that means the servers IP only belongs to a single entity. It's not hard to do, and is (I believe) the default configuration for an Apache install. So you may be able to do this on a shared host with a static IP on your account. You'll just need to ask the host I'd guess.
Tim Lytle