Original answer
Restricted (applies only if the subdomain is country.example.com)
constraints :subdomain => "country" do
get "programs/:id", to: redirect { |params, req| "http://#{req.domain}/#{req.subdomain}/programs/#{params[:id]}" }
end
Unlimited (applies to any subdomain, chicken.example.com, waffles.example.com)
get 'programs/:id', to: redirect { |params, req| "#{req.subdomain}/programs/#{params[:id]}" }
Change to fit all parameters
Route Globbing as indicated here . This should work:
constraints :subdomain => "country" do
get "*all", to: redirect { |params, req| "http://#{req.domain}/#{req.subdomain}/#{params[:all]}" }
end
[: all] . , , , , routes.rb