2

I have 3 websites running off one server (one IP), each with multiple subdomains. The httpd.conf file is rather large with multiple VirtualHost tags for each subdomain. Instead of adding to httpd.conf every time I add a new site or new subdomain, I would like to have it dynamically configured. Here's the layout...

the sites are located is

/var/www/html/[ownername]/[domain]/[subdomain]

so I want "sub.domain.com" to point to

 /var/www/html/theowner/domain.com/sub

and I want this.otherdomain.org to point to

 /var/www/html/someowner/otherdomain.org/this

How do I accomplish this in my httpd.conf file? Thanks.

1
  • Where would "domain.com" (no subdomain) be located in this setup?
    – faker
    Oct 30, 2011 at 17:06

4 Answers 4

2

If you're not looking to make the directory structure based on the owner of the site then you could easily accomplish this using the Apache2 vhost_alias module. I've used this in the past. In order to base it off the other like you are describing in your question you're going to need to do some fancy mod_rewrite writing but it likely won't be completely dynamic and require configuration to activate.

1

Sounds like the job for mod_vhost_alias:

http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html

3
  • Great minds think alike :) Oct 30, 2011 at 14:41
  • Heh. Funny how we are spending our Sunday here. :)
    – Rilindo
    Oct 30, 2011 at 14:43
  • I used mod_vhost_alias but it doesn't support a wildcard as a folder. The sites are, for example, /var/www/html/alec/google/www and something totally different and unrelated such as /var/www/html/somethingrandom/anothersite/admin
    – alecwhardy
    Nov 5, 2011 at 5:06
1

There are various options included in the apache2 mass virtual host documentation. In your case a mod_rewrite solution may work for you.

0

Another way to accomplish this would be to use a tool like puppet to manage both the folder structure as well as the vhost files. You could easily write or even find a vhost module to accomplish this. Then you use the conf.d directory to hold all of your vhost files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .