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 ");
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 ");
Are you requiring CGI at the top?
use CGI;
my $query=new CGI;
print $query->redirect('http://www.foo.com');
this works for me
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?
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