PHP 标头位置重定向到当前文件夹的根目录


PHP Header Location redirect to root of current folder

我从一个页面重定向到当前目录的索引.php文件。我在设置 GET 参数时这样做,我想做如下的事情。

header("Location: ?v=30");

这将在第 2.php 页上,重定向到 index.php?v=30。我知道我可以通过以下方式修复它:

header("Location: index.php?v=30");

但我想让 URL 更简单,我希望有一种方法可以采用前一种方式。

试试这个:

header("Location: ./?v=30");