Reputation: 16724
I have an app designed for multiple users on stuff.heroku.com
A landing page might look like stuff.heroku.com/controller/1/action/73
But the URL that I want to redirect there looks like sub.domain.com/hello
Similarly, I may want sub.domain.com/greetings to point to another landing page, this time at stuff.heroku.com/controller/1/action/74.
Once that works, I will want sub.anotherdomain.com/hello to map back to my same application, such as stuff.heroku.com/controller/1/action/87
How can I do that?
Upvotes: 1
Views: 2044
Reputation: 40277
You can do this in your application_controller and redirect there.
In Rails 2.3+ you can use rack middleware. Check out the Refraction gem -- it's setup to be a rack replacement for mod_rewrite
https://github.com/pivotal/refraction
Refraction.configure do |request|
if req.host == 'sub.domain.com'
req.rewrite! "http://sub.domain.com/#{req.path}"
end
end
The above will just take people from stuff.heroku.com to sub.domain.com -- but you could easily do your /hello rewrite if you want.
Upvotes: 2