将一些路径301重定向到其他新地址的写法

本教程需要在4.3.14中使用


例如,将以下类似地址 重定向到新地址

/news/123.html  重定向 /news-123.html
/bbs/321.html 重定向 /bbs-321.html


打开配置文件config/rewirte.php

"news\-123.html(.*)"  => 'index.php?s=api&c=rewrite&m=url&url=/news-123.html',

设置后,系统会自动重定向到新的地址了


那么,如果批量替换123表示数字呢,可以使用通配符的方式


"news\-([0-9]+).html(.*)"  => 'index.php?s=api&c=rewrite&m=url&url=/news-$1.html&p1=$1',

$1表示签名0-9的数字,p1表示1号参数,最大支持9个参数匹配替换

文档最后更新时间:2021-01-08 08:37:25
我来修改此文档(1) 不会操作怎么办?