tags:

views:

14

answers:

1

I'm trying to make a simple redirect work. I've gotten everything else to work just fine. For example, this works:

#!/usr/bin/env ruby

puts "Content-type: text/html"
puts
puts "<h1>blah</h1>"

But this doesn't work (this is where I get the "Premature end of script headers" error):

#!/usr/bin/env ruby

puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"

All of the other suggestions I've found say it's probably something to do with the #!/usr/bin/env ruby part of the script, but that doesn't make any sense to me since it works with the first example. Any suggestions?

It seems like Apache is parsing the headers I'm returning from the cgi script. Is there are way to turn that off?

A: 

You forgot the ending puts.

#!/usr/bin/env ruby

puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"
puts
Adrian