We Recommend

The Rails Way The Rails Way
Now, for the first time, there’s a comprehensive, authoritative guide to building production-quality software with Rails. Pioneering Rails developer Obie Fernandez and a team of experts illuminate the entire Rails API, along with the Ruby idioms, design approaches, libraries, and plug-ins that make Rails so valuable.


Posted By

jonhenshaw on 04/16/07


Tagged

redirect rails ruby on 301 ror


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

indianocean
stainless
Netzach


Ruby on Rails 301 Redirect


Published in: Rails 


This redirects visitors to a new URL using a 301 redirect. Using a 301 redirect is the safest way to let search engines like Google, Yahoo!, Live and Ask know your address has changed.

  1. def old_action
  2. headers["Status"] = "301 Moved Permanently"
  3. redirect_to "http://www.domain.com/"
  4. end

Report this snippet 

You need to login to post a comment.