Cakephp路由重定向基本路径

时间:2016-01-01 23:08:16

标签: php cakephp

我正在尝试制作这样的网址: www.website.com/www.website.com 重定向到 www.website.com/members/login 通过routes.php。 我现在有这个:Router::connect('/', array('controller' => 'home', 'action' => 'index'));

如何设置路线/以达到我想要的网址?

谢谢!

2 个答案:

答案 0 :(得分:2)

您只需更换一行:

Router::connect('/', array('controller' => 'home', 'action' => 'index'));

使用:

Router::connect('/', array('controller' => 'members', 'action' => 'login'));

但是,我相信你不想这样做

只需保持您的路线不变,并正确设置AuthComponent

class AppController extends Controller {

    // Pass settings in $components array
    public $components = array(
        'Auth' => array(
            'loginAction' => array(
                'controller' => 'members',
                'action' => 'login',
            ),
        //[...] rest of your Auth options
        )    
    );

有关详细信息,请参阅Cookbook 2.x: Authentication

答案 1 :(得分:0)

可能你在某个地方有AuthComponent而且'/'被设置为不允许。 $this->Auth->allow('/')应该有所帮助。