title: Rails 3 SSL routing redirects from https to http
body: <p>This question relates to this <a href="https://stackoverflow.com/questions/3634100/rails-3-ssl-deprecation">SO question and answer (rails-3-ssl-deprecation
  )</a>  where its suggested to handle ssl in rails 3 using routes.rb and routes like:</p>
  
  <pre><code>resources :sessions, :constraints =&gt; { :protocol =&gt; "https" }
  
  # Redirect /foos and anything starting with /foos/ to https.
  match "foos(/*path)", :to =&gt; redirect { |_, request|  "https://" + request.host_with_port + request.fullpath }
  </code></pre>
  
  <p><strong>My problem is that links use relative paths(i think thats the correct term) and once I'm on a https page all the other links to other pages on the site then use https.</strong></p>
  
  <p>1) Whats the best way to get back to http for pages where https isn't required? Do I have to setup redirects for all them(I hope note) or is there a better way. Would the redirects be like this:</p>
  
  <pre><code>match "foos(/*path)", :to =&gt; redirect { |_, request|  "http://" + request.host_with_port + request.fullpath }
  </code></pre>
  
  <p>2) If redirects back to http are required, how do I handle a case where I want all methods to be http except one? ie foos(/*path) would be for all foos methods. But say I wanted foos/upload_foos to use ssl. I know how to require it</p>
  
  <pre><code>scope :constraints =&gt; { :protocol =&gt; "https" } do
    match 'upload_foos' =&gt; 'foos#upload_foos', :via =&gt; :post, :as =&gt; :upload_foos 
  end
  </code></pre>
  
  <p>but if I put in the http redirect to the foos path what happens to https upload_foos?</p>