天空小小岛技术论坛

 找回密码
 注册
搜索
查看: 15773|回复: 0
打印 上一主题 下一主题

lighttpd 的 Discuz! rewrite 规则 bug 及解决方案

[复制链接]
跳转到指定楼层
1#
一粒米 发表于 2009-10-12 21:33:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
原来想得很简单,以为这样写就可以了。

错误的:

  1. url.rewrite-once = (
  2.         "^/archiver/((fid|tid)-[\w\-]+\.html)$" => "archiver/index.php?$1",
  3.         "^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
  4.         "^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page%3D$3&page=$2",
  5.         "^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
  6.         "^/tag-(.+)\.html$" => "tag.php?name=$1"
  7. )
复制代码
结果发现帖子那个 $3 一直传不进去,认真看了一下 lighttpd 的 rewrite 文档
http://trac.lighttpd.net/trac/wiki/Docs%3AModRewrite
结果发现 %3 表示的是 subdomain 1 name ,也就是说在语法中写这个,不被当成字串来识别
既然这样,那么就在 % 和 3 之间放置一个空的值以分隔开它们并且不影响最终转换的值。

我是这么写的

正常可用的:

  1. url.rewrite-once = (
  2.         "^/archiver/((fid|tid)-[\w\-]+\.html)$" => "archiver/index.php?$1",
  3.         "^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
  4.         "^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page%%53D$3&page=$2",
  5.         "^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
  6.         "^/tag-(.+)\.html$" => "tag.php?name=$1"
  7. )
复制代码
欢迎拍砖。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|天空小小岛  |京ICP备2025130156号|

GMT+8, 2025-6-22 04:31 , Processed in 0.096904 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表