0

I have an apache httpd server running on a linux server. The server's fqdn is www.example.com, but I have a dns alias of www.example2.com for the same server.

When I access the server using my browser and use http://www.example.com it serves the correct content, but if I use http://www.example2.com, I get the default content from my /var/www/html folder not the content from the /var/www/html2 folder.

A stripped-down copy of my httpd.conf file follows:

ServerName www.example.com:80
DocumentRoot "/var/www/html"

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

CustomLog "logs/access_log" combined
ErrorLog "logs/error_log"
LogLevel warn


<VirtualHost www.example2.com:80>
    ServerName www.example2.com:80
    DocumentRoot /var/www/html2
    CustomLog "logs/access_log2" combined
    ErrorLog "logs/error_log2"
<Directory "/var/www/html2">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
</VirtualHost>
dnraikes
  • 275
  • 1
  • 4
  • 14

1 Answers1

1
<VirtualHost *:80>
    ServerName www.example2.com
    DocumentRoot /var/www/html2
    CustomLog "logs/access_log2" combined
    ErrorLog "logs/error_log2"
    <Directory "/var/www/html2">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

The VirtualHost tag is for IP based filtering, to filter by host\server name use the ServerName directive.