有时我们要对程序中一些 url 进行一个美化的操作,为了用户更方便的设置 url 美化功能,我们要应用下对我们应用的url 进行一个规则的设置, 如我们在portal应用下加上url.php配置文件,文件内容如下:

<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
return [
    'List/index'    => [
        'name'   => '门户应用-文章列表',
        'vars'   => [
            'id' => [
                'pattern' => '\d+',
                'require' => true
            ]
        ],
        'simple' => true
    ],
    'Page/index'    => [
        'name'   => '门户应用-页面页',
        'vars'   => [
            'id' => [
                'pattern' => '\d+',
                'require' => true
            ]
        ],
        'simple' => true
    ],
    'Article/index' => [
        'name'   => '门户应用-文章页',
        'vars'   => [
            'id'  => [
                'pattern' => '\d+',
                'require' => true
            ],
            'cid' => [
                'pattern' => '\d+',
                'require' => false
            ]
        ],
        'simple' => true
    ],
    'Search/index'  => [
        'name'   => '门户应用-搜索页',
        'vars'   => [

        ],
        'simple' => false
    ],
];

上面的配置文件中,如数组键值List/index就是我们应用下一个操作,它不带应用名,这个操作的name属性是规则名,vars是这个url 的参数,然后每个参数有一些相应规则,可以参考上面的配置。

results matching ""

    No results matching ""