在Zend Framework 2應用程序中,我有兩種語言'nl'(默認)和'en'。請求的URL爲 'NL' 是這樣的:ZF2中的默認語言路由
/controller/action
和 '恩',如:
/en/controller/action
首先,我要路由/重寫默認語言設置爲:
/NL /控制器/動作
以便能夠隨後使用段路線等:
[:lang/[:controller/[:action]]]
我試圖與下面的正則表達式的路線(與前面負的樣子)
'lang' => array(
'type' => 'Zend\Mvc\Router\Http\Regex',
'options' => array(
'regex' => '/(?!en)(.*)',
'spec' => '/nl$2',
),
),
(這條路線不應該映射到控制器/動作,但應該只重寫URL到一個新的)
但我得到:
Page not found.
The requested controller could not be mapped to an existing controller class.
什麼是正確運作的路線?或者使用Web服務器重寫更好?
這就像我在我的代碼中,我沒有使用複製/粘貼。然而問題出在了正則表達式中。我編輯了我的問題。 – tihe