jtrupiano/rack-rewrite — Issue #25: Subdomain redirection yields infinite loop
Author: agraves
Created: 2012-02-01 09:05:05+00:00
State: open

Running on Heroku, Rails 3.0.11, latest stable rack-rewrite.

I have the following code in my config/environments/staging.rb:

Web::Application.configure do

# *snip*

config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
r301 %r{.*}, 'http://staging.example.com$&', :if => Proc.new {|rack_env|
rack_env['SERVER_NAME'] != 'staging.example.com'
}
end
end

Visiting "someapp.heroku.com" results in:

http://someapp.heroku.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/staging.example.com/

And so on. Help?