$this->redirect($this->indexUrl);
使用ThinkPHP快三天了,之前听说很简单,加上项目时间短,就没看文档,直接从别人的源代码开始学起了。
上手确实还算快,但最让我头疼的就是ThinkPHP的URL问题了,URL一会是这个,一会又变成那个了,尤其是我在重定向的时候,被搞得简直是要疯掉了。
问题:
$this->indexUrl =__ROOT__."/index.php/Admin/index";
$this-><span style="font-family: Arial, Helvetica, sans-serif;">redirect($this->indexUrl);</span>
当前URL为http://localhost/myproject/index.php/Home/Login
这段代码一执行,浏览器上的URL立马变成了http://localhost/myproject/index.php/Home/Loginmyproject/index.php/Home/index,
很明显,这次重定向的URL是原URL直接加上了传进去的URL。百度了一下,发现ThinkPHP有两种重定向手段,一种是利用Controller的$this->redirect()函数,另一种就是用$this