0

i am working on a cakephp 2.x .. my webapp url is like this "http://www.myweb.com/" .. so after then i am redirected a user to a gettingstarted page after login .. "http://www.myweb.com/users/gettingstarted"..... what i want is i want a url like this ..

 http://www.myweb.com/gettingstarted...

so in order to do this i cant make a controller name gettingstarted because in cakephp u cant create a controller if you dont have a similar table name in your db.. hope you get this ..may be it is possible .. but dont know how can i accomplish this ..

4

1 回答 1

0

添加规则routes.php(最好在任何其他规则之前)

//this will send www.web.com/gettingstarted to UsersController->gettingStarted()
Router::connect('/gettingstarted',
                 array('controller' => 'users', 'action'=>'gettingstarted'));
//this is the default route for www.web.com
Router::connect('/', array('controller' => 'users', 'action' => 'index'));

有了这个,我假设你gettingstarted在你的UsersController. 哦,你没有将变量传递给动作。否则规则会有点不同。

对于所有这些“url 更改”,请阅读Routes 文档。知道如何管理 url 会很有用。

编辑 如果您希望用户在成功登录后被重定向到入门页面,请更改用户控制器的登录操作

public function login() {
   //all your login actions
   //if user is logged in
   $this->redirect(array('controller'=>'users', 'action'=>'gettingstarted'));
}

这会将您重定向到www.web.com/gettingstarted

于 2013-07-02T19:43:54.860 回答