0

I have domain on name.com and I created two subdomain from DNS record

Type, Host,                   Answer,               TTL
A,    subdomain1.domain.com , EC2 IP,               300
A,    subdomain2.domain.com , EC2 IP same as above, 300


<VirtualHost *:80>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        ServerName subdmain1.domain.com
        ServerAlias www.subdmain1.domain.com

        Project related Configuration....

</VirtualHost>
<VirtualHost *:80>
        ServerName subdomain2.domain.com
        ServerAlias www.subdomain2.domain.com
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Second project code ....
</VirtualHost>

I did above configuration in apache2 of my EC2 server but When I access any subdomain that automatic always goes to first VirtualHost and second Virtualhost not working.

please Help me for configure both subdomain on ec2

Note: I'm using main domain.com on name.com website

1 Answer 1

2

May be you should remove '*' from virtualhost and provide respactive domain name and add domain name in your allowedhost in respactive settings file, it worked for me.

<VirtualHost subdmain1.domain.com:80>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ServerName subdmain1.domain.com
    ServerAlias www.subdmain1.domain.com
    Project related Configuration....
</VirtualHost>

and

<VirtualHost subdomain2.domain.com:80>
    ServerName subdomain2.domain.com
    ServerAlias www.subdomain2.domain.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Second project code ...
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.