LNMP下二级目录安装Discuz! X2.5伪静态规则

使用LNMP建站有很多优点,但是伪静态规则比LAMP麻烦一些,如果在使用军哥的LNMP建站时遇到一级目录是wordpress二级目录是Discuz时如果想让二级目录的discuz论坛也能实现伪静态的话需要自己去修改nginx.conf中默认虚拟主机的伪静态规则。
verycang



log_format  www.verycang.com  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
server
	{
		listen       80;
		server_name www.verycang.com verycang.com;
		index index.html index.htm index.php default.html default.htm default.php;
		root  /home/wwwroot/www.verycang.com;
		location /bbs/ {
		root   /home/wwwroot/www.verycang.com/bbs;
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 ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
	return 404;
}
}
		include wordpress.conf;
		location ~ .*\.(php|php5)?$
			{
				try_files $uri =404;
				fastcgi_pass  unix:/tmp/php-cgi.sock;
				fastcgi_index index.php;
				include fcgi.conf;
			}

		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
			{
				expires      30d;
			}

		location ~ .*\.(js|css)?$
			{
				expires      12h;
			}

		access_log  /home/wwwlogs/www.verycang.com.log  www.verycang.com;
	}



因为具体目录设置和Discuz版本和具体伪静态设置有别,请别直接复制和替换,具体设置还得看自己根据各自的情况修改,本文只是起个参考作用!

发表回复