Reputation: 749
If I access to http://walmart.example-site.com
it redirects me to http://walmart.example-site.com/communities/walmart
But I want it to redirect to http://example-site.com/communities/walmart
How can I fix?
My codes are.
routes.rb
constraints(:subdomain => /.+/) do
root :to => 'communities#subdomain_redirect'
end
communities_controller.rb
def subdomain_redirect
@community = Community.find_by_community_name(request.subdomain)
redirect_to @community
end
Upvotes: 0
Views: 193
Reputation: 1102
match "/stories/:name" => redirect {|params| "/posts/#{params[:name].pluralize}" }
match "/stories" => redirect {|p, req| "/posts/#{req.subdomain}" }
is this something you need?? Try to refer to the official routing guide under secion 3.12 Redirection.
Upvotes: 1