问题
I'm very confused...
I'm just getting my head around the whole DNS thing and, while it's simple enough to understand, I'm having trouble setting up subdomains using Route 53. I've set up the A Record for my new domain (for argument's sake, let's call it mydomain.com.
and it works perfectly! What I'd like to be able to do now is set up a subdomain (api.mydomain.com.
), which should point to mydomain.com/api
.
How can I achieve this using AWS?
Here's some more info on my architecture.
Domain Name Registrar ➜ Route 53 ➜ Beanstalk ➜ ELB ➜ Linux EC2 Instance ➜ Apache2
I don't care where I need to do it, so long as I can do it. Moreover, if there's a couple of ways to achieve it, then all the better! :)
Thanks in advance.
回答1:
You would want to setup a CNAME (as Ryan suggested):
api.mydomain.com. CNAME mydomain.com.
Then you would create a VirtualHost for "api.mydomain.com." in Apache and use mod_rewrite to rewrite http://api.mydomain.com/foo
to http://api.mydomain.com/api/foo
.
回答2:
Alternatively, it should be possible to create an S3 bucket api.mydomain,com
and set its static website hosting
to "Redirect all requests to another host name" and enter mydomain.com/api
there.
来源:https://stackoverflow.com/questions/17930972/how-can-i-use-aws-route-53-to-set-up-a-subdomain