Cakephp url:在主页上隐藏控制器名称

Cakephp url:在主页上隐藏控制器名称,php,cakephp,Php,Cakephp,当我用localhost/site\u名称打开网站时,url立即变成localhost/site\u name/default\u controller\u name 我如何隐藏它,使该主页上的url仅成为localhost/site\u name 编辑这是首页的默认控制器 public function index() { $this->set('list', $this->User->Mobilenetwork->find('list', array(

当我用localhost/site\u名称打开网站时,url立即变成localhost/site\u name/default\u controller\u name

我如何隐藏它,使该主页上的url仅成为localhost/site\u name

编辑这是首页的默认控制器

public function index() {


    $this->set('list', $this->User->Mobilenetwork->find('list', array(
            'fields' => array('id', 'network')
        )));


    if($this->Auth->user() ) 
    { 
        $this->redirect(array('controller' => 'contacts', 'action' => 'index'));
    }


   if ($this->request->is('post')) 
    {
      //saving data. this is a mess currently, i need to move majority of this code to the model
    }
您是否调整了“routes.php”文件,使根url直接指向“localhost/site\u name/default\u controller\u name”?如果没有,请转到Config文件夹中的routes文件并更改:

Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
(这是默认设置)对此:


*不确定您正在运行的CakePHP版本;以上是针对2.4的(虽然它可能也适用于早期版本)。

hm我尝试了一个(路由器::connect('/',数组('controller'=>'users','action'=>'index');),但结果是:这个网页在我的用户控制器中有一个重定向循环:if($This->Auth->user()){redirect..}和if($This->request->is('post')){您的意思是当您在中转到“root/mysite”时,会自动将url更改为“root/mysite/users”吗?另外,您使用的是什么版本的CakePHP?我应该发布哪些代码?我正在运行最新的Cakephpversion@jackel414是的,www.site.com变为www.site.com/users现在您的默认控制器是什么?这是我的书页吗?您是否将该操作添加到授权允许的操作中?
Router::connect('/', array('controller' => 'default_controller_name', 'action' => 'index'));