PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How to create subdomain on aws route 53

 September 21, 2022     amazon-route53, apache, dns, virtualhost     No comments   

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:

  1. admin.example.com
  2. 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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing