Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So what we are looking for is the ability to do the following:

  • We have an application that can load certain settings based on the domain that it is being accessed from. So if you come from we show a different logo and if you come from we show a different logo. The code is the same, running from same server just detects the domain on the run

  • Now we want to get a dedicated server (any suggestions?) that will enable us to point all the doamins that we want to this server (we change the DNS for the domains to that of our server) and then when the user goes to a certain domain they run the same application.

Now as far as I can understand we will need to create a "VirtualHost" in apache to handle this. Can we create a wildcard virtualhost that catches all the domains?

I am not an expert with Apache at all. So please forgive if this comes out to be a silly question. Any detailed help would be great.


share|improve this question

If you configure Apache to serve requests for an IP, all requests to that IP will serve the same content. The domains will be irrelevant to Apache.

You would use VirtualHost if you wanted to point different domains to different content on the same IP.

share|improve this answer

Yes, you want Apache name-based virtual hosting, and there are many references available to help you get it set up. You can set up virtual hosts for each domain name you want to host, on the same IP address, with different configurations for each domain. You can also set up a default which will be used for domain names that don't have specific virtual hosts defined.

One word of warning, though. If you're using SSL, then name-based virtual hosts don't work, and you'll need a different IP address for each SSL site.

share|improve this answer

In your VirtualHosts file you would specify the DocumentRoot to the shared directory

DocumentRoot "/home/somesharedfiles/public_html"

I would advice against a wildcard/catch all. That would allow anyone to point their domain to your server and load up your application.

Alternitively, you could use symlinks

ln -s somesharedfiles/public_html site1/public_html
ln -s somesharedfiles/public_html site2/public_html
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.