If you want to redirect the user to another page, all you have to do is return the following HTTP header :
print "Location: http://www.thenewurl.com", "\n\n";
Make sure that this is the first line that is sent to the browser.