简体   繁体   中英

how to redirect to another page using php after hosting my website

hello guys please help

How to redirect a page using php? i am using this one

header('location:quizsection.php?success=success');

It is working on localhost but after hosting my website it is not working

it is working on perfectly when i using with local server it is not working after i am hosting this on godaddy

and

path is also pefect

尝试使用:

header('location: /quizsection.php?success=success');

When I redirect, I go overboard to ensure redirection takes place. I do this:

$url = "quizsection.php?success=success";
header('Location: '.$url);
die("<html>
  <meta http-equiv='refresh' content='0; $url'>
  <body onload=\"location.replace('$url');\">
  <a href='$url'>$url</a>
  </body></html>");

Notice that I have a space after "Location:", which you do not have. If the header is ignored, I send HTML. It includes a meta tag to redirect. If that is ignored, the page uses Javascript to redirect. If that is ignored, the user sees the URL and nothing else. The user can click on it to get to the URL.

I actually have this in a function called redirect, so I just use:

redirect("quizsection.php?success=success");

If this doesn't work, it isn't a redirection problem. You need to check your directories and files. Something is not where you think it is or is not named what you think it is. I've personally spent days working on problems that were caused by a misnamed directory or file.

When you print something in PHP, it changes that into HTML and that's what the file shows. So when you think about it you have to do the following:

print("<script type=text/javascript>location.href = \"quizsection.php?success=success\";</script>");

Tell me if this works! If you want to delay the redirect do this:

print("<script type=text/javascript>function redirect() {location.href = \"quizsection.php?success=success\"} setTimeout(redirect, amountOfMilliseconds)</script>");

FYI, there are 1000 milliseconds in a second. Let me know if this works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM