discuz_ngixn配置

记录一下nginx下discuz的配置

vhost配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
server{
listen 80;
server_name bbs.haotoufa.com;
index index.html index.htm index.php;
root /home/wwwroot/haotoufa/bbs;
error_page 404 /index.php; //设置404界面,可以使html或者其他界面,这里根据需求跳转到首页;这里不能添加./404.html会跳转为302的
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
include /usr/local/nginx/conf/discuzx.conf;
log_format bbs '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/wwwlogs/access_bbs.log bbs;
}

discuz伪静态的一些配置,基本上就是前台的静态化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
rewrite ^([^\.]*)/scoremall\.html$ $1/plugin.php?id=it618_scoremall:scoremall&$2 last;
rewrite ^([^\.]*)/gwc\.html$ $1/plugin.php?id=it618_scoremall:gwc&$2 last;
rewrite ^([^\.]*)/productlist\.html$ $1/plugin.php?id=it618_scoremall:scoremall_list&$2 last;
rewrite ^([^\.]*)/uc\.html$ $1/plugin.php?id=it618_scoremall:scoremall_uc&$2 last;
rewrite ^([^\.]*)/store\.html$ $1/plugin.php?id=it618_scoremall:scoremall_store&$2 last;
rewrite ^([^\.]*)/storelist\.html$ $1/plugin.php?id=it618_scoremall:store_list&$2 last;
rewrite ^([^\.]*)/productlist-(.+)-(.+)-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:scoremall_list&$2=$3&page=$4&$5 last;
rewrite ^([^\.]*)/product-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:scoremall_page&pid=$2&$3 last;
rewrite ^([^\.]*)/uc-([0-9]+)-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:scoremall_uc&cid=$2&page=$3&$4 last;
rewrite ^([^\.]*)/store-(.+)-(.+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:scoremall_store&$2=$3&cid=$4&pid=$5&page=$6&$7 last;
rewrite ^([^\.]*)/storelist-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:store_list&page=$2&$3 last;
rewrite ^([^\.]*)/scoremall_wap\.html$ $1/plugin.php?id=it618_scoremall:wap&$2 last;
rewrite ^([^\.]*)/scoremall_wap-(.+)-([0-9]+)-([0-9]+)\.html$ $1/plugin.php?id=it618_scoremall:wap&pagetype=$2&cid=$3&page=$4&$5 last;
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
rewrite ^([^\.]*)/youhui.html$ $1/plugin.php?id=ljm_coupon last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
#判断手机版进行的一些操作
if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" )
{
#rewrite ^([^\.]*)/$ /forum.php?mod=guide&view=newthread&mobile=2 last;
}

if (!-e $request_filename) {
return 404;
}

另外一个网站的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
server{
listen 80;
server_name www.haotoufa.com haotoufa.com;
if ($host = 'haotoufa.com'){
rewrite ^/(.*)$ http://www.haotoufa.com/$1 permanent;
}
index index.html index.htm index.php;
root /home/wwwroot/haotoufa;
error_page 404 /404.html;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
include /usr/local/nginx/conf/discuzx.conf;
log_format haotoufa '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/wwwlogs/access.log haotoufa;
}

文章目录
|