I\'m moving an app to heroku and am having some issues with ssl and redirects.
I\'m on rails 3.1 and I\'ve tried forcing ssl with middleware in the environments producti
Since your 301 is being sent by the application, and the request can't even reach the application before hitting the middleware (on which rack-ssl runs), your only solutions are to change the middleware or to do the redirect before it even hits the middleware.
For the latter, you'd have to poke around Heroku. I don't use it myself. On a VPS deployment, you'd just add the redirect on your forward-facing web server (Apache, nginx) before it even hit the middleware. This seems like a common case, so I imagine Heroku might have something there for you.
For the former, it shouldn't be hard. The rack-ssl middleware is very, very simple, and it shouldn't be hard to monkeypatch it to suit your needs.
https://github.com/josh/rack-ssl/blob/master/lib/rack/ssl.rb#L58
I imagine that something like url.host = "www.myhost.com"
might be what you'd want (although you can probably tell there are probably more FQDN-agnostic ways to do it).