Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中发送头后url发生严重变化_Php - Fatal编程技术网

php中发送头后url发生严重变化

php中发送头后url发生严重变化,php,Php,我在php中使用header()函数来更改url并将用户重定向到另一个页面。 当用户在“localhost/admin/index.php”页面上时,输入登录信息并尝试登录,header()函数用于将用户重定向到页面 “localhost/admin/homepage.php”,但页面地址更改为“localhost/admin/localhost/admin/homepage.php” 标题(“位置:localhost/admin/homepage.php”) 你对这个问题的解决方案是什么? 谢

我在php中使用header()函数来更改url并将用户重定向到另一个页面。 当用户在“localhost/admin/index.php”页面上时,输入登录信息并尝试登录,header()函数用于将用户重定向到页面 “localhost/admin/homepage.php”,但页面地址更改为“localhost/admin/localhost/admin/homepage.php”

标题(“位置:localhost/admin/homepage.php”)

你对这个问题的解决方案是什么? 谢谢

试试这个:

header("Location: ./homepage.php");


路径必须是绝对URL或相对于当前URL的URL

header("Location: http://localhost/admin/homepage.php");


应该都能用。请确保在位置标头之后退出或停止执行,因为它不会阻止后续代码自行运行。

标头(“位置:localhost/admin/homepage.php”)将其更改为
标题(“位置:homepage.php”)
标题(“位置:http://localhost/admin/homepage.php"); 退出-RTM如果您对任何答案投了反对票,请留下评论,这样我们就知道问题出在哪里了!
header("Location: http://localhost/admin/homepage.php");
header("Location: homepage.php");
header("Location: /admin/homepage.php");