武汉SEO
时光静好,与君语;细水流年,与君同;繁华落尽,与君老...

迅睿CMS>正文

迅睿cms自定义URL函数

2024-05-21 17:23 gbl

config/custom.php

<?php

function ifcurl($data) {

    $aid = substr(hash("sha256",$data['title']), 0, 12); 

    $column= $data['dirname'];

    // $url = "/".$c."/".$aid.".html"; 

    $url = "/".$column."/".$aid.".html"; 

    dr_mkdirs(WRITEPATH.'myid/'); 

    file_put_contents(WRITEPATH.'myid/'. md5(trim($url, '/')).'.txt', $data['id']); 

    return $url; 

}

config/rewrite.php

<?php

if (CMSURI) {

    $myfile = WRITEPATH.'myid/'.md5(CMSURI).'.txt';

    if (is_file($myfile)) {

        $id = file_get_contents($myfile);

        if ($id) {

            return [

                CMSURI => 'index.php?c=show&id='.$id, // 这里写内容的地址

            ];

        }

    }

}


return [


    "list-([A-za-z0-9 \-\_]+)-([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2",  //【不带栏目路径】模块栏目列表(分页)(list-{dirname}-{page}.html)

    "list-([A-za-z0-9 \-\_]+)\.html" => "index.php?c=category&dir=$1",  //【不带栏目路径】模块栏目列表(list-{dirname}.html)

    "show-([0-9]+)\.html" => "index.php?c=show&id=$1",  //【不带栏目路径】模块内容页(show-{id}.html)


    "search\/([a-z]+)\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2",  //【共享模块搜索】模块搜索页(分页)(search/{modname}/{param}.html)

    "search\/([a-z]+)\.html" => "index.php?s=$1&c=search",  //【共享模块搜索】模块搜索页(search/{modname}.html)


    "([A-za-z0-9 \-\_]+)\/p([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2",  //【带栏目路径】模块栏目列表(分页)({dirname}/p{page}.html)

    "([A-za-z0-9 \-\_]+)\/([0-9]+)\.html" => "index.php?c=show&id=$2",  //【带栏目路径】模块内容页({dirname}/{id}.html)

    "([A-za-z0-9 \-\_]+)" => "index.php?c=category&dir=$1",  //【带栏目路径】模块栏目列表({dirname})


];







本文链接:https://www.0937.biz/post-3192.html