0

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 xyz.com we show a different logo and if you come from abc.com 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.

Thanks

Obaid
  • 101
  • 1

3 Answers3

1

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.

Warner
  • 23,756
  • 2
  • 59
  • 69
0

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.

Mike Scott
  • 7,993
  • 31
  • 26
0

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
Steve Robbins
  • 1,932
  • 5
  • 23
  • 26