ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷售客服

1835022288

028-61286886

投訴 已解決 使用title自定義函數(shù)作為URL規(guī)則,出現(xiàn)404 3 0

我的title已經(jīng)限定了字母和數(shù)字的,我想使用title自定義函數(shù)作為URL規(guī)則,

第一步、我在config/custom.php寫了一個(gè)函數(shù)titleurl

function titleurl($data) {
    $title = str_replace(" ", "-", $data['title']);
    return "/news/".$title.".html"; // 返回我自己的url規(guī)則:
}

第二步、在url規(guī)則里面填寫新標(biāo)簽:

{modname}/{titleurl($data)}.html

第三步、在config/rewrite.php,加入代碼

// 判斷url是否是來自自定義函數(shù)
if (CMSURI) {
    $myfile = WRITEPATH.'myid/'.md5(urldecode(CMSURI)).'.txt';
    if (is_file($myfile)) {
        $id = file_get_contents($myfile);
        if ($id) {
            return [
                CMSURI => 'index.php?c=show&id='.$id, // 這里寫內(nèi)容的地址
            ];
        }
    }
}

第四步、然后更新內(nèi)容url地址,使url地址生效

第五步、編寫偽靜態(tài)解析規(guī)則,因?yàn)檫@是你自己寫的函數(shù),所以無法用系統(tǒng)生成的代碼了

 "([\w]+)\/([\w]+)\.html" => "index.php?s=$1&c=show&title=$2",

為什么我訪問https://www.xxxx.cn/news/aaddb17339.html是404

訪問https://www.xxxx.cn/news/1.html可以。

是偽靜態(tài)解析規(guī)則寫錯(cuò)了嗎還是其他原因

解決方案