1. 文档地址:https://www.yiiframework.com/doc/guide/2.0/zh-cn/runtime-routing#using-pretty-urls
  2. get   request  method
     'index/<name:\w+>' => 'test/index'   // name是参数名,
    'index/<id:\d+>' => 'test/index' //id 为参数名,

     配置隐藏index.php脚本名,除了

    'showScriptName' => false, 以外,还需要在nginx(以nginx为例)配置rewrite 规则
    location / {
            index index.php index.html index.htm;
            rewrite ^/(.*)$ /index.php/$1 last;   // 这样url就可以不带脚本名请求了
        }

     为了避免样式不出来,再配置能访问到CSS,js等文件

    location ~* \.(jpg|jpeg|png|gif|css|js|bmp|html) {
            root "E:/project/myBlog/web";
        }

    这样当请求访问   http://localhost:8869/index/name  这种不带index.php脚本名的时候就能访问到了,并且样式也在。

  3. 'enableStrictParsing' => false, 设置为false的时候,可以不配置路由规则,会默认吧请求的path当做路由来解析,比如控制器是 test 方法名是actionFoo,那么不配置规则的情况下,访问http://localhost:8869/test/foo?name=shdfkjfkd 一样可以被解析
  4. 
    
    [
                        'pattern' => 'index/<sex:\d+>/<name:\w+>/<age:\d+>',
                        'route' => 'test/test',
                        'defaults' => ['sex' => 0, 'name' => 'xx', 'age' => 11],  // 这种是参数化配置,可以设置默认参数,
                    ],