天空小小岛技术论坛

 找回密码
 注册
搜索
天空小小岛技术网站 门户 查看主题

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

发布者: 一粒米 | 发布时间: 2009-10-12 21:33| 查看数: 16430| 评论数: 0|帖子模式

原来想得很简单,以为这样写就可以了。

错误的:

  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, 2026-6-11 03:20 , Processed in 0.100454 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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