1

2 场景:

header("Location: login/$username");

给我

http://localhost/login/login/mylogin

header("Location: /$username");

给我:

http://localhost/mylogin

两者都是错误的。我想http://localhost/login/mylogin

怎么了?

4

4 回答 4

5

利用

redirect('login/'.$username);
于 2012-08-23T12:50:00.610 回答
0

您不应该在 CI 中以这种方式操作标头。

对于重定向使用redirect()

和标题使用$this->output->set_header()

于 2012-08-23T13:49:23.907 回答
0

redirect(base_url("login/".$username));将根据您的要求重定向

于 2014-05-27T08:08:23.583 回答
0

试试这个。

echo '<script>window.location.href = "'.base_url("login/".$username).'";</script>';
于 2020-11-04T14:28:48.160 回答