如何在Yii2中使用多种语言启用 clean-urls 。
in - English
https://www.myfolder.com/en/restaurant/Bez_Gwiazdek-Warsaw
in - French
https://www.myfolder.com/fr/restaurant/Bez_Gwiazdek-Varsovie
in - Polish
https://www.myfolder.com/pl/Restauracja/Bez_Gwiazdek-Warszawa
答案 0 :(得分:0)
请查看此存储库https://github.com/codemix/yii2-localeurls#example-language-selection-widget
您需要更新urlManager
配置,例如
[
'language' => 'en',
'components' => [
'urlManager' => [
'class' => 'codemix\localeurls\UrlManager',
'languages' => ['en','pl','fr'],
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:\w+>/<action:\w+>/<slug:[A-Za-z0-9 -_.]+>' => '<controller>/<action>',
],
],
...
]