Redirect visitors to new Page

Sometime we need to redirect a visitor to another webpage. There is so many solution to redirect a user. I will show some of them which I know.

HTML

Code

<html>
<head>
<title>Html Redirect Page</title>
<meta http-equiv=”REFRESH” content=”5; url=http://www.mydomain.com”>
</ head >
<body>
You will be redirect within 5 seconds..
</body>
</html>

Description

<meta http-equiv=”REFRESH” content=”5; url=http://www.mydomain.com”>

// This is the part which is redirecting the current page to www.mydomain.com

content=”5; // This means it will wait 5 second and then redirect. you can increase and decrease this number.

PHP

Code

header(“Location: index.php“);

// You have to call this line before any output.

JavaScript

Code

<SCRIPT language=”JavaScript1.1″>
Redirect to main Page
location.replace(“index.php”);
</SCRIPT>

In some server non of above work as redirection. I don’t know why. But the following code work well. Does
anyone know why?

<?php
header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header (“Location: http://www.mydomain.com/”.time());
?>

Leave a Reply

Your email address will not be published. Required fields are marked *