in reply to url redirection

You output malformed headers.

I suggest outputting what HTTP actually specifies:

print "HTTP/1.0 302 Somewhere else\r\n"; print "Content-Type: text/html\r\n"; print $query->redirect('http://localhost/rbsaws/'), "\r\n"; print "\r\n"; # signal end of headers

Update: Fixed wrong HTTP result code, thanks moritz

Replies are listed 'Best First'.
Re^2: url redirection
by ikegami (Patriarch) on Dec 04, 2010 at 17:12 UTC

    yuck!

    For starters, you're ending the header a total of three times! Furthermore, ->redirect already sets the status line, so you're setting the status line twice with two different titles.

    All that's needed is:

    print $query->redirect('http://localhost/rbsaws/');

    The OP seems to want a Content-Type header for some reason. Is he trying to provide an HTML alternative for browsers that don't support 302 (not that there is such a thing)? If so, he could do the following to add the Content-Type header:

    print $query->redirect( -uri => 'http://localhost/rbsaws/', -content => 'text/html', ); print(q{Please click <a href="http://localhost/rbsaws/">here</a>});
      You're right, it works with only the
      print $query->redirect('http://localhost/rbsaws/');
      I believe I had tried this originally, but had other print statements in front of it which apparently causes a problem. Thanks.
Re^2: url redirection
by moritz (Cardinal) on Dec 04, 2010 at 16:36 UTC

    FWIW if you use CGI through Apache there's no need for the HTTP/1.0 part. And if you do a redirect, you shouldn't be printing 200 OK too.

    So far it worked fine for me to print nothing except the CGI->redirect header:

    use CGI; print CGI->redirect('http://example.com/');
      Not sure what I'm missing, but
      #!c:\perl\bin\perl.exe use strict; #use CGI::Carp qw(fatalsToBrowser); use CGI; use warnings; print $CGI->redirect('http://localhost/rbsaws/');
      produces a "CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers." for me.
Re^2: url redirection
by zoodog (Initiate) on Dec 04, 2010 at 16:39 UTC
    Re^2: url redirection
    by zoodog (Initiate) on Dec 04, 2010 at 17:07 UTC
      That took care of it. Thanks for the help.