联系官方销售客服

1835022288

028-61286886

开发框架 版主:迅睿框架研发组
自定义解析规则解析怎么弄
类型:迅睿CMS 更新时间:2021-07-19 18:46:09

自定义解析规则 解析 怎么弄

     "jianjie\/([0-9]+)\.html" => "index.php?c=jianjie&id=$1",
     "chanpin\/([0-9]+)\.html" => "index.php?c=chanpin&id=$1",
     "xinwen\/([0-9]+)\.html" => "index.php?c=xinwen&id=$1",
     "lianxi\/([0-9]+)\.html" => "index.php?c=lianxi&id=$1",

以上代码不起效果,下面动态链接 全部可以打开

index.php?c=jianjie&id=1
index.php?c=chanpin&id=1
index.php?c=xinwen&id=1
index.php?c=lianxi&id=1



回帖
  • 苦逼的民工
    #1楼    苦逼的民工
    2021-07-19 18:08:47
    Chrome 0
    <?php
    
    /**
     * URL解析规则
     * 例如:  114.html 对应 index.php?s=demo&c=show&id=114
     * 可以解析:  "114.html"  => 'index.php?s=demo&c=show&id=114',
     * 动态id解析:  "([0-9]+).html"  => 'index.php?s=demo&c=show&id=$1',
     */
    
    return [
    
    
    
    // 共享栏目---解析规则----开始
    
       "list-([a-z0-9 \-\_]+)-([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2",  //【共享栏目】模块栏目列表(分页)(list-{dirname}-{page}.html)
       "list-([a-z0-9 \-\_]+)\.html" => "index.php?c=category&dir=$1",  //【共享栏目】模块栏目列表(list-{dirname}.html)
       "show-([0-9]+)-([0-9]+)\.html" => "index.php?c=show&id=$1&page=$2",  //【共享栏目】模块内容页(分页)(show-{id}-{page}.html)
       "show-([0-9]+)\.html" => "index.php?c=show&id=$1",  //【共享栏目】模块内容页(show-{id}.html)
    
    
    	// 共享栏目---解析规则----结束
    
    
    
    	// 共享模块---解析规则----开始
    
       "([a-z]+)\/search\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2",  //【共享模块】模块搜索页(分页)({modname}/search/{param}.html)
       "([a-z]+)\/search\.html" => "index.php?s=$1&c=search",  //【共享模块】模块搜索页({modname}/search.html)
    
    
    	// 共享模块---解析规则----结束
    
    
    
    	// 独立模块---解析规则----开始
    
       "([a-z]+)" => "index.php?s=$1",  //【独立模块】模块首页({modname}/)
       "purchase\/page\-([0-9]+)" => "index.php?s=purchase&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "product\/page\-([0-9]+)" => "index.php?s=product&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "company\/page\-([0-9]+)" => "index.php?s=company&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "information\/page\-([0-9]+)" => "index.php?s=information&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "knowledge\/page\-([0-9]+)" => "index.php?s=knowledge&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "answers\/page\-([0-9]+)" => "index.php?s=answers&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "([a-z]+)\/([a-z0-9 \-\_]+)\/([0-9]+)" => "index.php?s=$1&c=category&dir=$2&page=$3",  //【独立模块】模块栏目列表(分页)({modname}/{dirname}/{page}/)
       "([a-z]+)\/([a-z0-9 \-\_]+)" => "index.php?s=$1&c=category&dir=$2",  //【独立模块】模块栏目列表({modname}/{dirname}/)
       "([a-z]+)\/([0-9]+)\/([0-9]+)\.html" => "index.php?s=$1&c=show&id=$2&page=$3",  //【独立模块】模块内容页(分页)({modname}/{id}/{page}.html)
       "([a-z]+)\/([0-9]+)\.html" => "index.php?s=$1&c=show&id=$2",  //【独立模块】模块内容页({modname}/{id}.html)
       "([a-z]+)\/([0-9]+)\.html\?(.*)" => "index.php?s=$1&c=show&id=$2",  //【独立模块】模块内容页({modname}/{id}.html)
       "([a-z]+)\/search\/(.+)" => "index.php?s=$1&c=search&rewrite=$2",  //【独立模块】模块搜索页(分页)({modname}/search/{param}/)
       "([a-z]+)\/search" => "index.php?s=$1&c=search",  //【独立模块】模块搜索页({modname}/search/)
    
    
    	// 独立模块---解析规则----结束
    
    	// 自定义---解析规则----开始
    
         "member\.html" => "index.php?s=member",
         "member\.html\?c=login&m=index" => "index.php?s=member&c=login&m=index",
         "member\.html\?c=register&m=index" => "index.php?s=member&c=register&m=index",
         "member\.html\?c=login&m=index&back=(.*)" => "index.php?s=member&c=login&m=index&back=$1",
         "member\.html\?c=register&m=index&back=(.*)" => "index.php?s=member&c=register&m=index&back=$1",
         "caigou.html" => "index.php?s=form&c=caigou&m=post",
         "purchase.html" => "index.php?s=member&app=purchase&c=home&m=index",
         "product.html" => "index.php?s=member&app=product&c=home&m=index",
         "jianjie\/([0-9]+)\.html" => "index.php?c=jianjie&id=$1",
         "chanpin\/([0-9]+)\.html" => "index.php?c=chanpin&id=$1",
         "xinwen\/([0-9]+)\.html" => "index.php?c=xinwen&id=$1",
         "lianxi\/([0-9]+)\.html" => "index.php?c=lianxi&id=$1",
    	// 自定义---解析规则----结束
    
    ];
    以上是解析的全部代码
  • 苦逼的民工
    #2楼    苦逼的民工
    2021-07-19 18:09:31
    Chrome 0
    一楼的 解析 不是404 而是302跳转 跳转到对应的模块内容页
  • 迅睿框架技术-刘光明
    #3楼    迅睿框架技术-刘光明
    2021-07-19 18:09:47
    Chrome 0
    动态页面本身就可以打开啊,任何伪静态页面都会转换成动态页面
    index.php?c=lianxi&id=$1
    你这个地址应该是二次开发的,这种开发不规范,开发的文件不能放在fcms目录,应该全部放在dayrui/App目录下面去
  • 迅睿框架技术-刘光明
    #4楼    迅睿框架技术-刘光明
    2021-07-19 18:13:14
    Chrome 0

    image
    第一框里面的包含了第二框,第二框应该放在第一框前面,顺序冲突了
  • 苦逼的民工
    #5楼    苦逼的民工
    2021-07-19 18:19:18
    Chrome 0
    迅睿框架技术-刘光明 文件放在dayrui/App目录下面的模块下面的Controllers文件夹里面
    <?php
    
    /**
     * URL解析规则
     * 例如:  114.html 对应 index.php?s=demo&c=show&id=114
     * 可以解析:  "114.html"  => 'index.php?s=demo&c=show&id=114',
     * 动态id解析:  "([0-9]+).html"  => 'index.php?s=demo&c=show&id=$1',
     */
    
    return [
    
    
    
    // 共享栏目---解析规则----开始
    
       "list-([a-z0-9 \-\_]+)-([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2",  //【共享栏目】模块栏目列表(分页)(list-{dirname}-{page}.html)
       "list-([a-z0-9 \-\_]+)\.html" => "index.php?c=category&dir=$1",  //【共享栏目】模块栏目列表(list-{dirname}.html)
       "show-([0-9]+)-([0-9]+)\.html" => "index.php?c=show&id=$1&page=$2",  //【共享栏目】模块内容页(分页)(show-{id}-{page}.html)
       "show-([0-9]+)\.html" => "index.php?c=show&id=$1",  //【共享栏目】模块内容页(show-{id}.html)
    
    
    	// 共享栏目---解析规则----结束
    
    
    
    	// 共享模块---解析规则----开始
    
       "([a-z]+)\/search\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2",  //【共享模块】模块搜索页(分页)({modname}/search/{param}.html)
       "([a-z]+)\/search\.html" => "index.php?s=$1&c=search",  //【共享模块】模块搜索页({modname}/search.html)
    
    
    	// 共享模块---解析规则----结束
    
         "jianjie\/([0-9]+)\.html" => "index.php?c=jianjie&id=$1",
         "chanpin\/([0-9]+)\.html" => "index.php?c=chanpin&id=$1",
         "xinwen\/([0-9]+)\.html" => "index.php?c=xinwen&id=$1",
         "lianxi\/([0-9]+)\.html" => "index.php?c=lianxi&id=$1",
    
    	// 独立模块---解析规则----开始
    
       "([a-z]+)" => "index.php?s=$1",  //【独立模块】模块首页({modname}/)
       "purchase\/page\-([0-9]+)" => "index.php?s=purchase&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "product\/page\-([0-9]+)" => "index.php?s=product&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "company\/page\-([0-9]+)" => "index.php?s=company&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "information\/page\-([0-9]+)" => "index.php?s=information&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "knowledge\/page\-([0-9]+)" => "index.php?s=knowledge&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "answers\/page\-([0-9]+)" => "index.php?s=answers&page=$1",  //【独立模块】模块列表(分页)({modname}/{page}/)
       "([a-z]+)\/([a-z0-9 \-\_]+)\/([0-9]+)" => "index.php?s=$1&c=category&dir=$2&page=$3",  //【独立模块】模块栏目列表(分页)({modname}/{dirname}/{page}/)
       "([a-z]+)\/([a-z0-9 \-\_]+)" => "index.php?s=$1&c=category&dir=$2",  //【独立模块】模块栏目列表({modname}/{dirname}/)
       "([a-z]+)\/([0-9]+)\/([0-9]+)\.html" => "index.php?s=$1&c=show&id=$2&page=$3",  //【独立模块】模块内容页(分页)({modname}/{id}/{page}.html)
       "([a-z]+)\/([0-9]+)\.html" => "index.php?s=$1&c=show&id=$2",  //【独立模块】模块内容页({modname}/{id}.html)
       "([a-z]+)\/([0-9]+)\.html\?(.*)" => "index.php?s=$1&c=show&id=$2",  //【独立模块】模块内容页({modname}/{id}.html)
       "([a-z]+)\/search\/(.+)" => "index.php?s=$1&c=search&rewrite=$2",  //【独立模块】模块搜索页(分页)({modname}/search/{param}/)
       "([a-z]+)\/search" => "index.php?s=$1&c=search",  //【独立模块】模块搜索页({modname}/search/)
    
    
    	// 独立模块---解析规则----结束
    
    	// 自定义---解析规则----开始
    
         "member\.html" => "index.php?s=member",
         "member\.html\?c=login&m=index" => "index.php?s=member&c=login&m=index",
         "member\.html\?c=register&m=index" => "index.php?s=member&c=register&m=index",
         "member\.html\?c=login&m=index&back=(.*)" => "index.php?s=member&c=login&m=index&back=$1",
         "member\.html\?c=register&m=index&back=(.*)" => "index.php?s=member&c=register&m=index&back=$1",
         "caigou.html" => "index.php?s=form&c=caigou&m=post",
         "purchase.html" => "index.php?s=member&app=purchase&c=home&m=index",
         "product.html" => "index.php?s=member&app=product&c=home&m=index",
    	// 自定义---解析规则----结束
    
    ];
    这样之后 还是301跳转到跳转到对应的模块内容页
  • 迅睿框架技术-刘光明
    #6楼    迅睿框架技术-刘光明
    2021-07-19 18:21:35
    Chrome 0
    那你写法不对了模块下面需要加模块目录
         "jianjie\/([0-9]+)\.html" => "index.php?s=模块目录&c=jianjie&id=$1",
         "chanpin\/([0-9]+)\.html" => "index.php?s=模块目录&c=chanpin&id=$1",
         "xinwen\/([0-9]+)\.html" => "index.php?s=模块目录&c=xinwen&id=$1",
         "lianxi\/([0-9]+)\.html" => "index.php?s=模块目录&c=lianxi&id=$1",
    满意答案
  • 苦逼的民工
    #7楼    苦逼的民工
    2021-07-19 18:33:55
    Chrome 0
    迅睿框架技术-刘光明 还是301到模块内容页下面是自定义页面代码
    <?php namespace Phpcmf\Controllers;
    
    /**
     * 二次开发时可以修改本文件,不影响升级覆盖
     */
    
    // 这里改成和文件名一样的名字
    class Jianjie extends \Phpcmf\Home\Module
    {
    
        public function index() {
            $this->_module_init();
            $data = $this->_Show(
                (int)\Phpcmf\Service::L('Input')->get('id'),
                [
                    'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
                    'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
                ],
                max(1, (int)\Phpcmf\Service::L('Input')->get('page')),
                1
            );
            
            // 这里指定新的模板
            \Phpcmf\Service::V()->display('jianjie.html');
        }
    
    
    }
  • 迅睿框架技术-刘光明
    #8楼    迅睿框架技术-刘光明
    2021-07-19 18:39:13
    Chrome 0
    开发者模式下提示什么内容
  • 苦逼的民工
    #9楼    苦逼的民工
    2021-07-19 18:46:09
    Chrome 0
    @迅睿框架技术-刘光明:现在好了,是浏览器缓存问题,谢谢