2014-07-02 99 views
0

我有途徑的Kohana 3.3更改URL

$c_i18n = Kohana::$config->load('i18n'); 

$allowedLangs = implode('|', array_keys((array)$c_i18n->allowedLangs)); 
$allowedLangs = "(?i:$allowedLangs)"; 
$defaultLang = $c_i18n->defaultLang; 


Route::set('default', '(<lang>(/<controller>(/<action>(/<id>))))', array(
    'lang' => $allowedLangs, 
)) 
    ->defaults(array(
     'lang' => $defaultLang, 
     'controller' => 'main', 
     'action' => 'index', 
     'id' => NULL, 
    )); 

我怎樣才能在默認情況下

穿上網址與語言例如用戶去:sait.com,這將是每一次sait.com/ENsait.com/news - > sait.com/en/news

回答

0

你可以嘗試像

Route::set('default', '(<lang>/)(<controller>(/<action>(/<id>)))', array(
    'lang' => '[a-zA-Z]{2}', 
)) 
->defaults(array(
    'lang' => 'en', 
    'controller' => 'main', 
    'action' => 'index' 
));