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