Correct redirect to Location


/ Published in: PHP
Save to your folder(s)

Just a function for correct redirecting

*UPD1* header added for Google Chrome


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.