分类
Dreamweaver

Nginx环境下supesite discuz wordpress rewrite 规则

在VPS上装的是口碑较好的 nginx,即LNMP. 但nginx下静态化规则与apache不同,需要重新配置,我目前用到的几款程序的静态化规则如下:wordpress 、supesite、discuz,nginx下静态化规则 ctrl+c +v following

//supesite nginx 静态化规则
rewrite ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2 last;
rewrite ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2 last;
rewrite ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2 last;
rewrite ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2 last;
rewrite ^/([0-9]+)$ /index.php?uid/$1 last;
rewrite ^/action(.+)$ /index.php?action$1 last;
rewrite ^/category(.+)$ /index.php?action/category/catid$1 last;
rewrite ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1 last;
rewrite ^/viewthread(.+)$ /index.php?action/viewthread/tid$1 last;
rewrite ^/mygroup(.+)$ /index.php?action/mygroup/gid$1 last;

//discuz nginx 静态化规则

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

//wordpress nginx 静态化规则
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注