I have purchased a domain (ex : xyz.com) from GoDaddy. Now I want to point a.xyz.com , b.xyz.com, and xyz.com to 3 subfolders inside my apache www folder in AWS ec2 instance.

I set up 000-default.conf with all the necessary virtual host entries, as well as I tried with different conf files (one per site name, e.g. : a.xyz.com.conf) , I also did a2ensite and apache reload.

One sample config for "a" subdomain. For "b" subdomain its b in place of a.

<VirtualHost *:80>
    ServerName a.xyz.com/
    ServerAlias www.a.xyz.com/
    DocumentRoot /var/www/html/a
    <Directory "/var/www/html/a">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =a.xyz.com/ [OR]
    RewriteCond %{SERVER_NAME} =www.a.xyz.com/

But all the sites pointing to same folder content (index.html inside main domain folder). In case of default conf config it picking up the first Vhost entry. In GoDaddy side I mapped (A record) every subdomain to the same elastic IP.

Without using Route53 how can I achieve the same ?


I think the problem just needs another pair of eyes. Even ifnyou wanted to, route 53 would not help - the problem is not in DNS if the browsers find the server

The ServerName and ServerAlias values should be domain names - not paths. Remove the '/" from the end - I believe that will fix it.

As an aside, those RewriteRules don't make sense to me. Maybe they need to be removed ?

  • Excellent. Thanks a ton. It worked. – Avik Jun 6 '20 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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