title: Specify Rails Controller Action Based on Domain
body: <p>I have a single application that supports two domains, <code>http://domain1.com</code> and <code>http://domain2.com</code>. Models, controllers and views are shared between the domains.</p>
  
  <p>In the past <code>http://domain1.com/user_type_2/faqs</code> and <code>http://domain2.com/user_type_2/faqs</code> were served up separately using the same controller action. Now, however, for SEO reasons, I want to completely remove the view associated with domain1 and route all user type 2 faq requests (from either domain) to <code>http://domain2.com/user_type_2/faqs</code> - continuing to use the existing controller and actions.</p>
  
  <p>How can I specify a route in routes.rb that redirects all requests from <code>http://domain1.com/user_type_2/faqs</code> to <code>http://domain2.com/user_type_2/faqs</code>?</p>
  
  <p>I've tried </p>
  
  <p><code>match 'http://domain1.com/user_type_2/faqs', :to =&gt; redirect('http://domain2.com/user_type_2/faqs')</code></p>
  
  <p>and</p>
  
  <p><code>constraints(:host =&gt; /domain1.com/) do
      match "/user_type_2/faqs" =&gt; redirect {|params, req| "//domain2.com/#{params[:path]}"}
    end</code></p>
  
  <p>Neither seems to work.</p>