1. 在需要使用.htaccess文件的目录下新建一个.htaccess文件
这个.htaccess文件一般discuz、dedecms等系统都自带
# .htaccess rewrite rule
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;
# end .htaccess rewrite rule
2.然后修改nginx.conf,在需要添加伪静态的虚拟主机的server{}中引入.htaccess文件
server{
include xxxx/.htaccess; ##(把这个改成你.htaccess文件的具体位置)
}
重启nginx.conf即可。
……