迅睿cms自定义URL函数
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})
];

评论