# 301 Redirect with Rails

**URL:** <https://www.ruby-forum.com/t/301-redirect-with-rails/102390>\
**Category:** Rails\
**Created:** [February 8, 2006, 2:32pm UTC](https://www.ruby-forum.com/t/301-redirect-with-rails/102390 "2006-02-08T14:32:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 8, 2006, 2:32pm UTC](https://www.ruby-forum.com/t/301-redirect-with-rails/102390/1 "2006-02-08T14:32:43Z")

</div>

I have been searching for a way to do this but haven’t found anything  
yet.

Can anyone please guide me to a resource or tell me how I would go  
about doing a 301 (Moved Permanently) redirect using Rails?

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 8, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/301-redirect-with-rails/102390/2 "2006-02-08T14:53:55Z")

</div>

Frank,

Give this a try in your controller:

def moved  
headers[‘Location’] = ‘http://the\_new\_location\_of\_your\_page.html’  
render :nothing =\> true, :status =\> 301  
end

On 2/8/06, softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Cody F.  
[http://www.codyfauser.com](http://www.codyfauser.com)

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 8, 2006, 5:56pm UTC](https://www.ruby-forum.com/t/301-redirect-with-rails/102390/3 "2006-02-08T17:56:47Z")

</div>

Hi Cody,

Thanks for your reply.

I believe that will do. I will check.

Thanks

Frank

Cody F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Frank,

Give this a try in your controller:

def moved  
headers[‘Location’] = ‘http://the\_new\_location\_of\_your\_page.html’  
render :nothing =\> true, :status =\> 301  
end

On 2/8/06, softwareengineer 99 wrote:

> 

–  
Cody F.  
[http://www.codyfauser.com](http://www.codyfauser.com)
