Trying to use 301 redirect, but the server does a 302

I am using the following code to do a 301 redirect in my controller:

headers[“Status”] = “301 Moved Permanently”
redirect_to “/somepage” and return

I am using nginx in front of mongrel cluster.

When I tested the URL at http://checkmyheaders.com/, it returns the
following info:

HTTP/1.1 302 Moved Temporarily
Server: nginx/0.7.59
Date: Mon, 27 Jul 2009 11:42:17 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie:
Status: 302

What gives?? Is mongrel or nginx changing this to a 302 somewhere along
the way??

Hi Yanni,

have you tried this:

redirect_to “/somepage”, :status=>:moved_permanently

Read
http://api.rubyonrails.org/classes/ActionController/Base.html#M000662.

Regards
Nicolai

That worked great! Thanks! I guess the old way does not work with the
latest version of rails.

Nicolai Reuschling wrote:

Hi Yanni,

have you tried this:

redirect_to “/somepage”, :status=>:moved_permanently

Read
http://api.rubyonrails.org/classes/ActionController/Base.html#M000662.

Regards
Nicolai

Yanni.

the “old” way is almost two years old:
http://dev.rubyonrails.org/changeset/7820
That’s close to eternity in Rails world.

Glad I could help!

Nicolai