I need to redirect users that visit a certain page without providing specific parameters in a query string. How to redirect users to another page the right way? So that the sear
<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.new-url.com");
exit();
?>
The moved permanently is what helps with search engines.
<?php
Header("HTTP/1.1 302 Moved Temporarily");
Header("Location: http://www.new-url.com");
exit();
?>
<?php
/* Redirect browser */
header("Location: http://www.google.com");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
Instead of http://www.google.com, you can write your own URL where you want to redirect your page.
if($condition){
header('Location: http://example.com');
exit();
}
will do it. Don't forget the exit()
!