Ruby on Rails 301 redirection Ruby on Rails 301 redirection ruby-on-rails ruby-on-rails

Ruby on Rails 301 redirection


You should be able to redirect with status 301 by adding this to your controller action:

redirect_to "http://host.com/foo/foo_slug", :status => 301

See the API documentation for redirect_to for details.

And there should be no problem with redirecting upper-cased URLs to lowercased versions, although this may be better handled by something at the HTTP server layer such as Apache mod_rewrite rules.


For 301 redirection write this code in your controller:

headers["Status"] = "301 Moved Permanently"

redirect_to "http://host.com/foo/foo_slug" # in your case

And for second question, use capitalise or down case if you mentioned hardcode url.

Otherwise use ruby interpolation by putting whole url in string