How to redirect to current page in php?

How to use header redirection to redirect it to the current page?

EDIT: I am trying to reload the page currently being displayed in the browser.

+3
source share
7 answers

EDIT: I'm trying to reload its currently displayed page in a browser.

PHP alone cannot force page refresh. You will need to use javascript:

<input type="button" onclick="window.location.reload(true)" value="Reload It" />

The bit .reload(true)tells the browser to perform a hard update (i.e., get a new copy of the web page from the server).

+2
source
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+3
source

, . , , :

 header("Location: ".$url);
 exit(1); // Needed!
+1

mypage.php:

header('Location: /mypage.php');

manual.

0
$url = 'mypage.php';
header('Location: ' . $url);
die('<a href="' . $url . '">Click Here</a> if you are not redirected.');

mypage.php. , .

0

HTML PHP ... , (Meta )

<meta http-equiv="refresh" content="10;url=http://www.yoursite.com/yourpage.htm" />

:

  • content =
  • url = , .
0

URL-, $_SERVER['REDIRECT_URL'] .

0

Source: https://habr.com/ru/post/1737451/


All Articles