因为服务器性能不能满足当前的网站访问需求,所以最近把所有的网站项目都转到Nginx构架下面,虽然负载能力有了明显的提高,网站响应也比以前快了很多,不过还是有一些水土不服,特别是一个使用rewrite规则的网站。Discuz论坛就是其中的一个。下面是Nginx实例配置代码,留作记录吧。
[cc lang=’vim’ ]
server {#discuz配置实例
listen 80;
server_name www.xxx.com xxx.com *.xxx.com;
root /var/www/discuz;
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;
}
}
[/cc]
不错的文章,内容观念明确.禁止此消息:nolinkok@163.com
不错的文章,内容无与伦比.禁止此消息:nolinkok@163.com