CakePHP缺少控制器语言路由

时间:2013-02-28 18:45:55

标签: cakephp

我将CakePHP应用程序从一个服务器移动到另一个服务器,但是在新服务器上运行会出现此错误,请记住ita是URL看起来像这样的语言路径 http://www.c2cistanbul.com/ita/post/263

缺少控制器 错误:找不到ItaController。 错误:在文件中创建下面的类ItaController:app / controllers / ita_controller.php

<?php
class ItaController extends AppController {

    var $name = 'Ita';
}
?>

注意:如果要自定义此错误消息,请创建app / views / errors / missing_controller.ctp

路线

Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
$par = Router::parse(substr($_SERVER['REQUEST_URI'],6));
Router::reload();
Router::connect('/',  array('controller' => 'site', 'action' => 'home','ita'));
Router::connect('/admin', array('controller' => 'utente', 'action' => 'logged'));
$url = array('home');   
if (in_array($par['controller'],$url))
{
    Router::connect($par['controller'].'/*/', array('controller' => 'site','action' => $par['controller']));
}

$lang = array('ita', 'eng', 'deu', 'rus','fra');
if (in_array($par['controller'], $lang)){
    Router::connect('/ita/_(.*)', array('controller' => 'site', 'action' => 'stdpage','ita',$par['action'],));
    Router::connect('/eng/_(.*)', array('controller' => 'site', 'action' => 'stdpage','eng',$par['action']));
    Router::connect('/fra/_(.*)', array('controller' => 'site', 'action' => 'stdpage','fra',$par['action']));
    Router::connect('/rus/_(.*)', array('controller' => 'site', 'action' => 'stdpage','rus',$par['action']));

    Router::connect('/ita/', array('controller' => 'site','action' => 'home','ita'));
    Router::connect('/eng/', array('controller' => 'site','action' => 'home','eng'));
    Router::connect('/fra/', array('controller' => 'site','action' => 'home','fra'));
    Router::connect('/rus/', array('controller' => 'site','action' => 'home','rus'));

    Router::connect('/ita/'.$par['action'].'/*/', array('controller' => 'site','action' => $par['action'],'ita'));
    Router::connect('/eng/'.$par['action'].'/*/', array('controller' => 'site','action' => $par['action'],'eng'));
    Router::connect('/fra/'.$par['action'].'/*/', array('controller' => 'site','action' => $par['action'],'fra'));
    Router::connect('/rus/'.$par['action'].'/*/', array('controller' => 'site','action' => $par['action'],'rus'));

1 个答案:

答案 0 :(得分:0)

得到了但是谢谢大家,错过了

$par = Router::parse(substr($_SERVER['REQUEST_URI'],6));
抱歉。