Posted By

kirik on 08/06/09


Tagged

redirect


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Correct redirect to Location


 / Published in: PHP
 

Just a function for correct redirecting

UPD1 header added for Google Chrome

  1. function redirect($url = './', $permanent=false)
  2. {
  3. if($permanent)
  4. {
  5. header('HTTP/1.1 301 Moved Permanently');
  6. header('Status: 301 Moved Permanently');
  7. header('Retry-After: 120');
  8. header('Location: ' . $url, true, 301);
  9. header('Connection: Close');
  10. }
  11. else
  12. {
  13. header('Status: 200'); // For google chrome
  14. header('Location: ' . $url);
  15. }
  16. exit('If your browser does not support automatic redirect, <a href="' . $url . '" title="proceed">click here</a>.');
  17. }

Report this snippet  

You need to login to post a comment.