I've tried to follow a few different tutorials on this, but can't quite get it to work.
I have all of my DNS for my domain (example.com) in Route 53. Works fine.
My top level domain (A record) points to my load balancer (AWS) as an alias. This points to an EC2 server and works fine.
I want to add a subdomain (client.example.com), but I'm not quite sure where to add this and what type of records I need. I want this to point to a directory on the same EC2 server as my top level domain (which would have the path example.com/client). I don't want it to redirect, just serve the files from this directory.
Not sure if I need to create a new hosted zone or not, what to put in the zone, what to point it at, and if I need to modify anything on my server (like a rewriterule).
Any direction would be appreciated.
Best Answer
I havent worked with much AWS, but the general way of doing it will be as follows.
Let say currently you have
example.com
hosted in Route53, so Route53 is the authoritative nameserver for yourexample.com
zone. Now if you want a subdomain calledclient.example.com
which again needs to point to the same IP address whereexample.com
.So in that case create a CNAME record where
example.com
will be canonical name andclient.example.com
will be alias record.Once this is done now
example.com
andclient.example.com
will both resolve to the same IP address i.e to the Load balancer.If you prefer to share the same
DocumentRoot
ofexample.com
toclient.example.com
you have noting extra to do. But if you want to serve different content then create a Name-Based Virtual host in Apache.Update
As you want both
demo.example.com
andexample.com
to serve different contents you have to create a Name-Based virtual host in Apache.The configuration will be looking like
The above configuration will serve file from
/var/www/main
if request is forhttp://example.com
orhttp://www.example.com
. And it will serve files from/var/www/content
if the request is forhttp://demo.example.com
.