yii2路由urlManager配置详解

yii2路由urlManager配置详解

    • urlManager参数详解

urlManager参数详解

component域中添加urlManager模块

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm' => '@vendor/npm-asset',
    ],
    'components' => [
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],     
    ],
    'params' => $params,
];

enablePrettyUrl : false 隐藏入口文件index.php, ex: /index.php/post/100 ==>>/post/100
enableStrictParsing : true 启动url严格匹配模式,匹配规则 yii\web\UrlManager::rules
rules : url 规则,注意定义不匹配时的默认路径(apache) yii\web\UrlRule
suffix : url 添加后缀名

你可能感兴趣的:(Yii框架,Linux,Php)