I switched my app's domain, and the redirect works for urls that use http, but I have some links lurking around on the web using HTTPS that aren't redirecting.
For instance, http://myolddomain.com redirects just fine, but https://myolddomain.com results just returns a generic server error. Is it possible to redirect these links? I'm using rails 3 and heroku.
UPDATE:
I'm trying the rack-rewrite gem. Here's the code that I'm adding to my production environment file:
#mod_rewrite using rack-rewrite gem
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
rewrite '^https://www.myolddomain.com/(.*)$', 'https://www.mynewdomain.com/$1'
rewrite '^https://myolddomain.com/(.*)$', 'https://www.mynewdomain.com/$1'
end
It's successfully redirecting https://myolddomain.com but not https://www.myoldomain.com. It's also throwing an error for the ssl certificate, "Server's certificate does not match the URL."
For your site to even respond on https://myolddomain.com it will need to have the certificate for myolddomain.com else it will fail with a certificate mismatch as Heroku have a wildcard cert *.herokuapp.com by default on all apps - the certificate will be checked before any rack modules are executed.
If you want to handle the https traffic at Heroku your only option will be to buy a an SSL and use the SSL endpoint addon.
Or, you could use an external server to redirect the old domain (with the certificate for the loaded) to redirect to the new domain on Heroku.
One way you can do it is with apache or nginx. They both support url redirect. You would just need to specify two rules, one for http and another one for https. Although, Im positive you could just write a regex to include both.
You could write your custom rules in a .htaccess file in the root of your application
See links below for more info.
How do I get mod_rewrite working on Heroku?
http://wiki.nginx.org/HttpRewriteModule
http://httpd.apache.org/docs/current/mod/mod_rewrite.html