Tom Rossi
Tom Rossi

Reputation: 12066

How do you redirect to a new host and maintain the path information in your routes.rb

I ran into this issue and couldn't find a concise and beautiful solution for the configuration. I would like to redirect all requests that match a specific pattern to another host and include any path provided in the request.

http://host1.com/something           -> http://host2.com/something
http://host1.com/something/something -> http://host2.com/something/something

Upvotes: 0

Views: 119

Answers (1)

Tom Rossi
Tom Rossi

Reputation: 12066

This was the solution and I hope it saves someone time!

  get 'something(/*path)', to: redirect {|params, request| 'http://host2.com' + request.path}

Upvotes: 1

Related Questions