未添加Codeigniter国际化i18n尾随斜杠

未添加Codeigniter国际化i18n尾随斜杠,codeigniter,internationalization,routes,Codeigniter,Internationalization,Routes,我有一个项目正在进行中,现在[管理部分几乎完成](我知道有点晚)我正试图实施该项目。 我认为除了输入http://localhost/my_project当我的\u项目在其中安装了CI的目录下工作时,我被重定向到以下http://localhost/my_project/enhome(在en之后没有尾随斜杠)有什么想法吗 预期结果http://localhost/my_project/en/home,不仅是主控制器,而且所有控制器的行为都相同 .htaccess、base\u url和index

我有一个项目正在进行中,现在[管理部分几乎完成](我知道有点晚)我正试图实施该项目。 我认为除了输入
http://localhost/my_project
当我的\u项目在其中安装了CI的目录下工作时,我被重定向到以下
http://localhost/my_project/enhome
(在
en
之后没有尾随斜杠)有什么想法吗

预期结果<代码>http://localhost/my_project/en/home,不仅是主控制器,而且所有控制器的行为都相同

.htaccess
base\u url
index\u页面
设置正确(所有作品均不带i18n)

routes.php已售罄

$route['default_controller'] = "home";
$route['404_override'] = '';

// URI like '/en/about' -> use controller 'about'
$route['^(en|de|fr|nl)/(.+)$'] = "$2";

// '/en', '/de', '/fr' and '/nl' URIs -> use default controller
$route['^(en|de|fr|nl)$'] = $route['default_controller'];
编辑
我想我用的是Ellisab的“new”。抱歉链接错误(适用于1.7 CI版本)。

此库有点旧,很久以来从未更新过作者,它适用于CI 1.7,但此处的更新版本与CI 2.1兼容。*相同的库,但更新版本的工作方式与您可以从此处下载的方式相同


因此,在一些挖掘之后,我在核心文件中发现了问题,在这个发布的脚本的底部有一个变量
$new\u url
,它正在响应
重定向http://192.168.1.184/my_project/enhome
没有“修复”。我刚刚在那里添加了
/
,效果非常好。我想知道这里发生了什么,这是不是
修复了

function MY_Lang() {
    parent::__construct();

    global $CFG;
    global $URI;
    global $RTR;


    $this->uri = $URI->uri_string();
    $this->default_uri = $RTR->default_controller;

    $uri_segment = $this->get_uri_lang($this->uri);
    $this->lang_code = $uri_segment['lang'] ;

    $url_ok = false;
    if ((!empty($this->lang_code)) && (array_key_exists($this->lang_code, $this->languages)))
    {
        $language = $this->languages[$this->lang_code];
        $CFG->set_item('language', $language);
        $url_ok = true;
    }

    if ((!$url_ok) && (!$this->is_special($uri_segment['parts'][0]))) // special URI -> no redirect
    { 
      // set default language
      $CFG->set_item('language', $this->languages[$this->default_lang()]);

      $uri = (!empty($this->uri)) ? $this->uri: $this->default_uri;
      //OPB - modification to use i18n also without changing the .htaccess (without pretty url) 
      $index_url = empty($CFG->config['index_page']) ? '' : $CFG->config['index_page']."/";
      $new_url = $CFG->config['base_url'].$index_url.$this->default_lang()."/".$uri;
      echo "Redirect triggered to ".$new_url;

      //header("Location: " . $new_url, TRUE, 302);
      // exit;
    }
}

你如何重定向它?你能发布那个代码吗?我不会在其他项目上重定向任何库(i18n做所有的工作),它是开箱即用的。但在这一个有问题。我使用新的:)从github。我用了我最近的项目相同的一个,没有问题,在所有我使用它在不同的项目也!(没有问题)。但现在这个新问题突然出现,在“自动重定向”(从
localhost/my_project/whatever
localhost/my_project/en/whatever
)之后没有插入尾随斜杠,它实际上重定向到
localhost/my_project/enwhatever