1、修改config/custom.php //xxxurl 地址 function xxxurl($data) { if ($data['pid'] == 0) { return $data['dirname']."/"; // 不存在子栏目就以当前栏目 } $pcat = dr_cat_value($data['topid']); return "/".$pcat['dirname']."/".$data['dirname']."/"; // 顶级目录/当前目录/ } 现在前台各个链接都是自定义静态链接,但是点击打开后所有自定义链接都是404错误。 2、rewrite.php添加后所有内容为: 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}) ]; // 判断url是否是来自自定义函数 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, // 这里写内容的地址 ]; } } } ?问题:我的动态链接是: index.php?c=category&id=$1&page=$2 而不是: index.php?c=category&dir=$1&page=$2 3、根目录下:.htaccess修改如下 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_REFERER} !^$ [NC] RewriteCond %{HTTP_REFERER} !chenchr.com [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] RewriteCond %{HTTP_REFERER} !google.com.hk [NC] RewriteCond %{HTTP_REFERER} !baidu.com [NC] RewriteRule !.(js|ico|pe?g|bmp|css|doc|jpg|gif|mp3|zip|rar|png)$ /index.php[NC,L] SetOutputFilter DEFLATE AddOutputFilterByType DEFLATE text/html text/css application/x-javascript ErrorDocument 404 /HttpErrors/404.html