I'm using Amazon Web Services to host my site and since I am going to use the ELB service I will need to redirect all my traffic from http://example.com to http://www.example.com.

Is this possible through the DNS?

I am using Route 53 as my DNS. Any hints would be appreciated.

link|improve this question
Given the protocol identifiers in your URLs, you can already see that it is impossible. You want two completely unrelated protocols in ways they have not been designed for ;) – STATUS_ACCESS_DENIED Mar 2 '11 at 19:33
feedback

migrated from stackoverflow.com Mar 2 '11 at 19:09

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 10 down vote accepted

You cannot do redirects in DNS.

Instead, you need an HTTP server that sends HTTP 301 redirects in response to requests for mysite.com.
Most registrars offer redirect servers; consult yours.

link|improve this answer
Indeed my registrar offers a free redirect service. Thank you! – Alex Mar 2 '11 at 19:42
feedback

To supplement SLaks response, a common way to handle this is to use mod_rewrite in Apache and send a 301 redirect. In other words, let ELB send the traffic to an Apache server running on your EC2 instance. Then have Apache send a redirect if the hostname does not include www.

Here's a sample snippet:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^/(.*) http:/www.example.com/$1 [R,L]

Hope that helps.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.