关于伪静态规则的问题

csshaier 2010-07-06 11:21:55
用的是无忧CMS的系统,程序里面关于Rewrite部分的规则是这样的

' Rewrite 规则
function rewriterule(byval html)
if Createhtml = 2 then
html = replacex(html, "(content.asp\?id=)(\d+)(&Page=)(\d+)(&Diy=)(.*?)(///)", rewritecontent & "$6_$2-$4" & rewriteext & "")
html = replacex(html, "(content.asp\?id=)(\d+)(&Diy=)(.*?)(///)", rewritecontent & "$4_$2" & rewriteext & "")
html = replacex(html, "(content.asp\?id=)(\d+)(&Page=)(\d+)", rewritecontent & "$2-$4" & rewriteext & "")
html = replacex(html, "(content.asp\?id=)(\d+)", rewritecontent & "$2" & rewriteext & "")
html = replacex(html, "(channel.asp\?id=)(\d+)(&Page=)(\d+)", rewritechannel & "-$2-$4" & rewriteext & "")
html = replacex(html, "(channel.asp\?id=)(\d+)", rewritechannel & "-$2" & rewriteext & "")

end if
rewriterule = html
end function


想在加一条 将tag.asp?Keyword=关键词这样的地址 转换为 tag-关键词-页码.html形式的规则,要怎么写呢?
...全文
223 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
竹贤侄 2010-07-10
  • 打赏
  • 举报
回复
$6_$2-$4 这个不是什么无优自定义的方法,

这个是正则表达式里面的分组,
html = replacex(html, "(content.asp\?id=)(\d+)(&Page=)(\d+)(&Diy=)(.*?)(///)", rewritecontent & "$6_$2-$4" & rewriteext & "")

$1就是第一个括号的内容 也就是(content.asp\?id=)
依此类推.
yangtututu 2010-07-09
  • 打赏
  • 举报
回复
html = replacex(html, "(tag.asp\?Keyword=)(.*?)(///)", rewritechannel & "$6_$2-$4" & rewriteext & "")


你还要找到 replacex 这个方法实体,看 $6_$2-$4 是怎么跟 前面的参数绑定的,因为无忧CMS 没有研究过,所以只能提供这些给你参考
  • 打赏
  • 举报
回复
html = replacex(html, "(tag.asp\?Keyword=)(.*?)(&Page=)(\d+)", rewritetag & "-$2-$4" & rewriteext & "")

根据你上面的规则:content.asp对应rewritecontent,channel.asp对应rewritechannel,所以tag.asp也应该对应一个rewritetag。这个rewritetag怎么写,要参照rewritecontent和rewritechannel的内容。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧