如何在yii2中将此网址设为http://localhost/yii-application/frontend/web/site/booking更简单?
http://localhost/yii-application/frontend/web/site/booking
我需要更简单:
http://localhost/controller/action
我如何使用.htaccess处理此问题
答案 0 :(得分:0)
通过放置此网址管理器:
'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