在 url 路由 yii2 中使用静态 url
use static url in url routing yii2
我有一个旧网站,现在我用新版本的 yii 框架编写了它,我想更改 url,但由于 SEO 问题,我想保留我的旧 url。
现在当用户输入 www.mysite.pre/car/details/10908
我想要应用程序呈现 www.mysite.pre/site/show_detail/10908
我如何在 yii2 路由中处理它?
假设您在 SiteController 中执行了此操作 class
public function actionShow_detail($id) {}
在您的配置文件中添加:
// ...
'components' => [
// ...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// ...
'car/details/<id:\d+>' => 'site/show_detail',
],
],
],
有关 Yii 2 路由的更多详细信息和信息,请参阅 "Routing and URL Creation" section of The Definitive Guide to Yii 2.0。
我有一个旧网站,现在我用新版本的 yii 框架编写了它,我想更改 url,但由于 SEO 问题,我想保留我的旧 url。
现在当用户输入 www.mysite.pre/car/details/10908
我想要应用程序呈现 www.mysite.pre/site/show_detail/10908
我如何在 yii2 路由中处理它?
假设您在 SiteController 中执行了此操作 class
public function actionShow_detail($id) {}
在您的配置文件中添加:
// ...
'components' => [
// ...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// ...
'car/details/<id:\d+>' => 'site/show_detail',
],
],
],
有关 Yii 2 路由的更多详细信息和信息,请参阅 "Routing and URL Creation" section of The Definitive Guide to Yii 2.0。