Multiple Domains on one IP Address using Apache Virtual Server

Using Apache Virtual Servers it is easy to make multiple domains point at the same IP address displaying different content. You just have to add the following lines to the file /etc/httpd/conf/httpd.conf and restart apache:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.first-domain.com
ServerAlias first-domain.com *.first-domain.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
ServerName www.second-domain.com
DocumentRoot /var/www/samples
</VirtualHost>


In this setup www.first-domain.com is displaying the content of /var/www/html while www.second-domain.com is displaying the content of /var/www/samples.

One thought on “Multiple Domains on one IP Address using Apache Virtual Server”

  1. I was recommendd this bpog bby my cousin. I’m nott sure whethesr this post is writen by him aas nobody else
    know such destailed about mmy problem. You’re incredible!
    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>