Reputation: 43
i am trying to redirect the page using header location in xampp but it is not working and redirecting to localhost/dashboard
i used the following code for simple redirecting in localhost , i placed my site in htdocs/test/ and files in that are index.html and index.php, the index.php code is as follows
<?php
header("Location:/index.html");
?>
when i am trying to access http://localhost/test/index.php it is not going to localhost/test/index.html but it is redirecting to http://localhost/dashboard/
Upvotes: 0
Views: 6244
Reputation: 9
try:
<?php
echo "<script type=\"text/javascript\" language=\"javascript\">
window.location.replace(\"index.html\");
</script>";
?>
Upvotes: 0
Reputation:
i know your problem and this should fix it.
in your index.php
<?php
header('Location: ./index.html');
?>
where ./
represents current directory
Upvotes: 0
Reputation: 3485
Check in your php.ini file that output_buffering=On; then use this code to redirect to index.html
<?php
ob_start();
if (headers_sent()) {
die("Redirect failed.");
}
else{
exit(header("Location: index.html"));
}
?>
You can get details of ob_start from here http://php.net/manual/en/function.ob-start.php
Upvotes: 2