nginx上支持伪静态

    我先写好了伪静态,譬如Discuz的伪静态规则:

# nginx 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 nginx rewrite rule

  然后命名为rewrite.conf放在了网站下,没想到重启时提示:

/etc/init.d/nginx reload

Reloading nginx!nginx: [emerg] open() "/www/server/nginx/conf/rewrite.conf" failed (2: No such file or directory) in /www/server/nginx/conf/vhosts/abc.conf:69

原来这个nginx的版本只支持放在nginx/conf/rewrite目录下,把文件拷贝进这个文件后重启后正常,规则生效,无法自定义调用路径。

2018/9/18 11:13:00 技术杂谈