Issue
I am running Apache on an EC2 instance. I have added an A record with EC2 instance IP in route 53 and updated Name Server with registrar. DNS resolution is working for me.
I have two sites on two folders like this: www/admin and www/client.
I want to create two sub-domains for these two sites like this:
- admin.example.com
- client.example.com
I tried with a CNAME record with name: admin.exmaple.com and value example.com/admin which is not working.
I found one solution here:
The problem with this approach is that whatever I type in subdomain is redirected to root directory.
How do I create subdomains in route 53 without creating vhost in apache?
Solution
Your issue here isn't really anything to do with Route 53 and DNS, it all comes down to apache.
The role of DNS is to route a domain name (or subdomain name) to a specific server (so, example.com and admin.example.com).
From what you say here:
The problem with this approach is that whatever i type in subdomain is redirected to root directory
That seems to be successfully working, in that the requests that you make to your subdomains are making it to your server.
If you're only using a singular server, the role of VirtualHosts is to recognise what domain someone arrived at your server from, then route them accordingly.
For example:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example.com/public
</VirtualHost>
<VirtualHost *:80>
ServerName admin.example.com
DocumentRoot /var/www/example.com/admin/public
</VirtualHost>
Doing something of this ilk will provide the separation you're after in regards to being able to get a different page based on your subdomain.
Answered By - Doug Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.