0

What I want to do is,

When someone make request to http://www.domain.com/api, the server forward this request to http://main.domain.com/api

Now I configure my rails routes on www.domain.com like this:

namespace :api do
  namespace :v1 do
    resources :users
  end

 namespace :v2 do
   resources :sessions
 end
 match 'v:api/*path', :to => redirect("http://main.domain.com/api/%{path}")
end

currently The http request is not accepted on main.domain.com

Any suggestion ?

1 Answers1

0

In your ApplicationController

 def redirect_api
     if request.host == 'http://www.domain.com/api'
         redirect_to 'http://main.domain.com/api'
     end
 end
Wraithseeker
  • 1,884
  • 2
  • 19
  • 34