clean URL & URL 在 yii2 中用 .htaccess 重写
clean URL & URL rewrite with .htaccess in yii2
如何在 yii2 中使这个 url 更简单 http://localhost/yii-application/frontend/web/site/booking like http://localhost/controller/action?
http://localhost/yii-application/frontend/web/site/booking
我需要像这样更简单的:
http://localhost/yii-application/controller/action
我如何使用 .htaccess 处理此问题
通过把这个 url 管理器 :
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => [
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
] ]
你会实现的
http://localhost/yii-application/controller/action
如何在 yii2 中使这个 url 更简单 http://localhost/yii-application/frontend/web/site/booking like http://localhost/controller/action?
http://localhost/yii-application/frontend/web/site/booking
我需要像这样更简单的:
http://localhost/yii-application/controller/action
我如何使用 .htaccess 处理此问题
通过把这个 url 管理器 :
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => [
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
] ]
你会实现的
http://localhost/yii-application/controller/action