Category Archives: amazon-ec2-windows

apache not handling subdomains properly virtual hosts windows

I have searched many a post and tried every different way of configuring this in httpd.conf.

I'm running Apache 2.4 on windows server 2012 with PHP 5.6 and MySQL. On an amazon EC2 instance. I have all the correct security settings, and I have also setup my dns properly in route S3 to point to my EC2, have A entries for my subdomains. The primary domain www.mydomain.com is working fine and pointing to the correct location htdocs. However my subdomains aren't being mapped to the folder I've defined as below:

NameVirtualHost ip.ip.ip.ip:80      

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot c:/Apache24/htdocs
    DirectoryIndex index.php index.htm index.html
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot c:/Apache24/htdocs/sub1
    ServerName sub1.mydomain.com
    DirectoryIndex index.php index.htm index.html
    ErrorLog logs/sub1-error.txt
    CustomLog logs/sub1-access.txt common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot c:/Apache24/htdocs/phpMyAdmin
    ServerName phpmyadmin.mydomain.com
    DirectoryIndex index.php index.htm index.html
    ErrorLog logs/phpmyadmin-error.txt
    CustomLog logs/phpmyadmin-access.txt common
</VirtualHost>

All help greatly appreciated.

I also have these entries in my HOSTS file

    ip.ip.ip.ip mydomain.com
ip.ip.ip.ip *.mydomain.com
ip.ip.ip.ip sub1.mydomain.com
ip.ip.ip.ip phpmyadmin.mydomain.com

ip.ip.ip.ip is my server's public IP address.