tags:

views:

116

answers:

3

Hello, I want to perform an HTTP redirect, but the way I am currently doing it isn't working. When I try redirect it just prints the status code, and the location header:

my $q = new CGI;
q->redirect(" http://www.google.com ");
+2  A: 

Are you requiring CGI at the top?

use CGI;
my $query=new CGI;
print $query->redirect('http://www.foo.com');

this works for me

Marcos Placona
A: 

Is there a purpose the spaces around the URL? Depending on what the CGI library does, those might present a problem. I could see it converting your URL to %20http://www.google.com%20 which would not load correctly...

Edit: It doesn't seem to do anything harmful when I test it, other than being passed right through to the browser. On the other hand you are missing a use, a $ and a print in your code -- is this the actual code you are trying, or something else?

calmh
A: 

I figured out what the problem was, I trying to redirect after i had printed the 200 ok status, which would result in me printing the URL to the page instead of redirecting to it

Zerobu
This is why should post the actual code you are trying, not something different. :)
calmh