业务经理

微信扫描以上二维码

028-61286886

技术咨询

/book/diyizhangjie.html 章节伪静态怎么写

迅睿框架 更新 2021-12-04 20:39:03 qqd

/book/diyizhangjie.html  章节路径是这样的

diyizhangjie  这段每个章节的标题拼音


请问rewrite.php里面伪静态怎么写  来对应/book/diyizhangjie.html  这个路径


章节动态路径 是这个 /index.php?s=book&c=son&m=show&id=10244


非常感谢




{xunruicms_img_title}



方案

  • 迅睿框架联合创始人 #1 · 2021-12-04 00:05:34
    插件不支持这种自定义字段的url,他必须有id才行,例如/book/10244.html--------非要这么来book/diyizhangjie.html,只能对son控制器进行二次开发,来找内容,否则内容是找不到的,就是404了
  • qqd #2 · 2021-12-04 08:07:04
    那获取内容页面拼音/xiaoshuoneirongye/10244.html这个如何写
  • LandQ #3 · 2021-12-04 08:31:55
    1、打开 config/custom.php 添加自定义方法function book_url($data){ $py = \Phpcmf\Service::L('pinyin')->result($data['title']); \Phpcmf\Service::L("cache")->set_file("dr_book_".$py, $data['id'], "dr_book"); return "/book/" . $py . ".html";}2、URL规则上填

    3、打开 config/rewrite.php 把原来的内容规则/***********************独立模块测试规则:内容页面的伪静态解析*************************/"([a-z]+)\/show\/([0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',改成"([a-z]+)\/([a-z0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',4、打开 dayrui/App/Book/Controllers/Show.php 找到第6行的index方法public function index() { $this->_module_init(); $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')) );}改成public function index() { $this->_module_init(); $id = \Phpcmf\Service::L('Input')->get('id'); if ($cid = \Phpcmf\Service::L("cache")->get_file("dr_book_".$id , "dr_book")) { $id = $cid; } $this->_Show( (int)$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')) );}5、更新URL

  • qqd #4 · 2021-12-04 20:39:03
    LandQ 兄弟首先非常感谢你 但是按你操作 还是不能打开页面,拼音转换时可以的

迅睿系统漏洞

图片格式转化
图片格式转化(2026-10-17)
修复百度编辑器里的内容图片没有转换为webp格式 历史文章列表不显...
站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
图书阅读系统
图书阅读系统(2026-10-14)
全站移动端样式适配 首页分类 Tab 横滑容器,左右渐变滚动提示 ...
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;