Centos – Subdomains not taking effect CentOS

apache-2.2centossubdomain

Hey I'm using webmin to manage the apache server on my CentOS box and I'm trying to set my subdomains to a different directory. However the subdomain and the actual domain both go to the exact same page

<VirtualHost *>
DocumentRoot "/home/windshear-gaming.com/public_html/forum"
ServerName forum.windshear-gaming.com
</VirtualHost>

<VirtualHost *>
DocumentRoot "/home/windshear-gaming.com/public_html/portal"
ServerName windshear-gaming.com
</VirtualHost>

Thats how I setup the virtual hosts for the two different subdomains. Everything else was just left the same.

Best Answer

In your /etc/httpd/conf/httpd.conf

### Section 3: Virtual Hosts
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin username@domain.tld
    DocumentRoot /home/windshear-gaming.com/public_html/portal
    ServerName windshear-gaming.com
    ErrorLog logs/windshear-gaming.com-error_log
    CustomLog logs/windshear-gaming.com-access_log common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin username@domain.tld
    DocumentRoot /home/windshear-gaming.com/public_html/forum
    ServerName forum.windshear-gaming.com
    ErrorLog logs/forum.windshear-gaming.com-error_log
    CustomLog logs/forum.windshear-gaming.com-access_log common
</VirtualHost>

That will answer your domain and subdomain in every IP your webserver is listening to correctly.

Related Topic