Jump to content

How to redirect users?


Flying Sagittarius

Recommended Posts

no html tags before the header. all the php you want, but no echos;

 

-----------------------top of the page-------------------

<?php    //no whitespace before this tag

 

your code with no echos;

header('Location:http://www.anotherlocation.com');

?>  no whitespace between code and this tag

---------------------------------------------------------

 

<?php
  echo '<meta http-equiv="refresh" content="0;url=http://www.someurl.com/" />';
  exit();
?>

 

This can be outputed at anytime and will attempt to redirect the user to someurl.  It's best to put exit(); after calling this so that a non regular browser (ie: PERL masquerading as a browser) will not get any additional info.

PHP worked the best for me.  I've learned that meta- and javascript redirects are discouraged by W3.  .htaccess only works on Linux.

 

Even so, I still can't figure out output buffering.  If there's a way to redirect without using headers, I'd appreciate it being posted here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.