Re: Redirecting to a new URL under mod_ruby

Nick Bicknell <[email protected]>
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
Okay, I figured it out one way to do it, stolen from here: 

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/50294
 
The following seems to work fine instead of the print statement: 
 
q.header("Location" => caller_url)
 
Thanks,
Nick
 
> On Tue, 22 Jun 2004 15:22:02 -0700, Nick Bicknell wrote:
>>  Hi,
>>  
>>  I'm using Ruby 1.8.1 with mod_ruby 1.2 under apache 1.3.2x on Mac os 
>>  X 10.3.4.  
>>  
>>  I have a cgi script that looks like this: 
>>  
>>  #!/usr/bin/ruby
>>  
>>  require "cgi"
>>  
>>  q = CGI.new
>>  caller_url = q.referer.gsub( /(.*)\?*.*/, '\1' )
>>  
>>  # do some work here.... 
>>  
>>  print "Location: #{caller_url}\n\n"
>>  
>>  What I am trying to accomplish is to have the cgi script do a little 
>>  work (e.g., delete a record from the database, or add one, etc.) and 
>>  to then redirect the browser automatically to a new URL, in this 
>>  case, the one that called it.  The issue is that the above code 
>>  doesn't seem to work - it just prints the text "Location: 
>>  http://etc/etc/"
>>  
>>  Any advice would be most appreciated.
>>  
>>  Thanks,
>>  Nick
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.