我正在尝试创建这样的URL:CCD_ 1,www.website.com
重定向到www.website.com/members/login
通过routes.php。我现在有这个:Router::connect('/', array('controller' => 'home', 'action' => 'index'));
如何设置路由/
以到达我想要的url?
谢谢!
您只需替换行:
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。
可能您在某个地方有AuthComponent,并且'/'
被设置为不允许。$this->Auth->allow('/')
应该会有所帮助。