# Headers and page redirecting

**URL:** <https://www.ruby-forum.com/t/headers-and-page-redirecting/165539>\
**Category:** Ruby\
**Created:** [April 15, 2009, 12:57am UTC](https://www.ruby-forum.com/t/headers-and-page-redirecting/165539 "2009-04-15T00:57:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![devo9er](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@devo9er](https://www.ruby-forum.com/u/devo9er)\
**Post date:** [April 15, 2009, 12:57am UTC](https://www.ruby-forum.com/t/headers-and-page-redirecting/165539/1 "2009-04-15T00:57:43Z")

</div>

I am creating a simple contact form with field validation to make sure  
users are entering valid data. I am posting the form data via CGI to the  
same page so it can run the validation, if there are errors the page is  
the same and the fields are highlighted where there are errors. All that  
works fine. Now I am trying to redirect the user to a new page depending  
on certain conditions determined by their post data. HOW? I have found  
stuff like:

cgi = CGI.new(“html4”)  
cgi.header(“Location” =\> “/some/other/page”)

But it doesn’t work? Is it because headers are already sent or  
something? I feel like what I am trying to do should be relatively easy.  
Thanks in advance!
