Reputation: 1843
I want to make a rewrite to another domain so that http://domain1.com/abc would point to http://domain2.com/xyz. This is my code:
require 'rack/rewrite'
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
rewrite '/abc', 'http://domain2.com/xyz'
end
But after I open http://domain1.com/abc, Im being pointed to http://domain1.com/http:/domain2.com/xyz . How could I rewrite it so that it would point to the right place?
Upvotes: 2
Views: 485
Reputation: 8432
You need to use a redirect for this, not a rewrite. Rewrites just change the URL that your app sees whilst redirects do an actual HTTP 301.
require 'rack/rewrite'
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
r301 '/abc', 'http://domain2.com/xyz'
end
Upvotes: 1