6

We can't change the server configuration files, so we need to do our redirections at the rails level.

I have no problem with path redirections to external sites, like:

match "/meow" => redirect("http://meow.com/")

The issue is with the subdomains. I need to redirect for example:

http://my.example.com => http://example.com

How can this be done using routes.rb?

4

4 に答える 4

4

私は最終的に次のようなことをしました:

constraints :subdomain => "meow" do   
  match "/" => redirect { |params| "http://www.externalurl.com" }
end
于 2012-12-05T04:41:45.040 に答える
0

このrailscastがお役に立てば幸いです。

http://railscasts.com/episodes/221-subdomains-in-rails-3

http://railscasts.com/episodes/123-subdomains

于 2012-12-05T01:30:42.653 に答える