是否有可能通过使用 PHP 将用户重定向到不同的页面?
假设用户访问了 google www.example.com/page.php ,我想把他们重定向到 google www.example.com/index.php ,如果不使用元信息刷新,该怎么做呢? 这可能吗?
如何在 PHP 中进行重定向?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- weixin_38166347 2019-07-25 13:29关注
function Redirect($url, $permanent = false){ if (headers_sent() === false) { header('Location: ' . $url, true, ($permanent === true) ? 301 : 302); } exit();} Redirect('http://www.google.com/', false);
别把die()/exit()落下!
解决 无用评论 打赏 举报