• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
天道酬勤
echo "See you,World!";
博客园    首页    新随笔    联系   管理    订阅  订阅

apache,nginx,lighttpd rewrite demo

-----------apache----------

<IfModule mod_rewrite.c> 
RewriteEngine On 
       RewriteRule ^archiver/((fid|tid)-[0-9]+\.html)$ archiver/index.php?$1
       RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
       RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
       RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
       RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
</IfModule>

 

-----------lighttp------------

url.rewrite-once = ("^(.*)/archiver/([a-z0-9\-]+\.html)$" => "$1/archiver/index.php?$2",
                    "^(.*)/forum-([0-9]+)-([0-9]+)\.html$" => "$1/forumdisplay.php?fid=$2&page=$3",
                    "^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "$1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3",
                    "^(.*)/space-(username|uid)-(.+)\.html$" => "$1/space.php?$2=$3",
                    "^(.*)/tag-(.+)\.html$" => "$1/tag.php?name=$2"
                    )

 

url.rewrite-once = (
        "^/archiver/((fid|tid)-[\w\-]+\.html)$" => "archiver/index.php?$1",
        "^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
        "^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page%%53D$3&page=$2",
        "^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
        "^/tag-(.+)\.html$" => "tag.php?name=$1"
)

-----------nginx------------

   location /{
                       rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
                       rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
                       rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
                       rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
                       rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
                       rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
          }


posted @ 2011-11-04 15:35  enimo  阅读(327)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3