Apache Config

After doing much googleing, and much reading of how to set up virtual hosts in apache, I finally figured it out. The documentation on this is very poor. All I wanted to do was set up apache to handle multiple domains, and to be able to handle *.domain.com and point it to a certain location. I want to be able to have domain.com, www.domain.com, something.domain.com, and *.domain.com all point to different places. Here’s what I came up with, and after consulting with others, this seems to be correct. I’ve also tried it and have it working on familylearn’s box too.

<VirtualHost *>
DocumentRoot /var/www/html
ServerName www.bagunsa.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/html/post_nuke
ServerName jonas.bagunsa.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/html/test
ServerName bagunsa.com
ServerAlias *.bagunsa.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/html/post_nuke
ServerName www.jonasfam.com
ServerAlias jonasfam.com *.jonasfam.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/html/utahrealestateadvisor
ServerName www.utahrealestateadvisor.com
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/html/blog
ServerName www.jonasblog.com
ServerAlias jonasblog.com *.jonasblog.com
</VirtualHost>

I learned that you have to put all of your specific entries for a domain first, then you put the catchall last. The ServerName also can’t have any wildcards in it, as they should go into the ServerAlias field.

Filed under General by

Comment

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Comment

Disclaimer: According to the new FTC guidelines, I have to tell you that sometimes I get paid for recommending certain products on my blog. Not all the time, but often. Sometimes I get products for free (ok...fine...most of the time I get stuff for free).

Register Login