Direct traffic from domain.org to domain.com

55 Views Asked by At

I am hosting my website on amazon web services. I use a beanstalk application and have an A-record that directs the address www.domain.com to the beanstalk. I also have the same domain but with a .org at the end. I also created an A record that points the domain.org to the same beanstalk application. This works. The problem is that I will buy a ssl certificate for the domain.com and therefore I need the user to be directed to the domain.com when he/she enters domain.org. I tried adding a CNAME record for the domain.org address with the value domain.com. The result is that the user ends up in the correct page but the address in the url bar is domain.org which might cause a problem since the certificate is for domain.com.

2

There are 2 best solutions below

0
On BEST ANSWER

You can use Amazon S3 to do this.

  1. Create an S3 bucket called domain.org
  2. Enable Static Web Hosting on the new bucket by choosing "Redirect all requests to another host name"
  3. Set domain.com or www.domain.com as that other domain
  4. If you are using Route53 for your DNS, you can create an Alias record for domain.org to point to your bucket. If you are not using Route53, then create a CNAME to your bucket's public URL.

You can easily do similar things for domain.com -> www.domain.com if you are using Route53.

0
On

DNS cannot do any redirection. That's purely HTTP-level material. You would need to configure your .org vhost to do that, e.g. on apache:

<VirtualHost *:80>
   ServerName www.domain.org
   RedirectPermanent / http://www.domain.com
</VirtualHost>

Your CNAME is basically pointless. All it does is point a hostname at another hostname, which causes your DNS resolver to fetch the IP of that "another host". It then uses that IP as the IP for the original name. e.g.

domain.org -> CNAME pointer -> domain.com -> a.b.c.d

which then does an HTTP request to the a.b.c.d IP with

Host: domain.org

in the http request header.