For a Rails application hosted on Heroku, we are using Zerigo DNS Add-on to point a custom domain (say mydomain.org) to point to the Heroku app. We have SSL certificate registered for mydomain.org
Now, we would want mydomain.com to redirect to mydomain.org. We tried implementing redirect rules at the controller/rack level. Doesn’t work. The browser URL still points to .com instead of .org
Has anybody faced the same problem with an Heroku app!!?
I’ve used the following technique to redirect from “example.com” to “www.example.com” (as described here, http://docs.heroku.com/custom-domains). This might work in your case to redirect from .com to .org.
In app/controllers/application_controller.rb:
In your case, you would point the DNS records for your .com and .org domains to your app running on Heroku. Your app would check the HTTP_HOST to see if it specifies your .org URL. If it does not, then it would redirect to your .org URL.