Perl Python CGI script page redirection

After processing your Perl/CGI script you may need to redirect it to a specific link. To do this, most of the cases the choice is below code.
print "Location: http://127.0.0.1/abc.html\n\n";

But I found that this is not work most of the cases, May be I'm missing something. If anyone know this, can guide me.

But I used to write the below line instead of above one. This one work with me since this is the HTML code printing into browser using Perl.
print '<meta http-equiv="refresh" content="0;url=http://127.0.0.1/abc.html">';

There is another way to redirect. Which is printing the JavaScript code into browser. I'm giving one example to do this.
<script type="text/javascript">location.href='http://127.0.0.1/form.html';</script>

By the way, Above will work for Python/CGI too. Appreciate to post other ways if you guys know.

More Perl article is here http://icfun.blogspot.com/search/label/perl

Comments

Matt said…
This works for me in Python, perhaps not the best way, but it seems to work.

print "Status: 302 Moved"
print "Location: http://www.somedomain.com/"