rewrite

discuz在Nginx0.8.34下的伪静态规则

discuz论坛在Nginx下的rewrite规则,修改完后restart nginx

bear@bear-laptop:/etc/nginx/sites-available$ vi bbs.njava 
server {
        listen   80;
        server_name bbs.njava.com;

        access_log  /var/log/nginx/bbs.njava.access.log;

        location / {
            root /home/bear/Sites/bbs.njava;
            index index.html index.htm index.php;

            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;    
          }

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                set $path_info "/";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
                  }
               fastcgi_param SCRIPT_FILENAME /home/bear/Sites/bbs.njava/$real_script_name;
               fastcgi_param script_name $real_script_name;
               fastcgi_param path_info $path_info;
               include /etc/nginx/fastcgi_params;
         }
}

Tags: , ,

星期一, 22 3 月, 2010 服务器 没有评论
1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr