今天在配置某个程序网站的nginx伪静态出现了一个错误:

[emerg] directive “rewrite” is not terminated by

第一次遇到这样的情况,自然就记录下解决过程。

伪静态原来的代码是:

rewrite ^/school/joblist/(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html?(.+)$ /school/index.php?c=job&city=$1&edu=$2&uptime=$3&pr=$4&job1=$5&job1_son=$6&job_post=$7&page=$8&keyword=%{QUERY_STRING} last;

nginx提示错误就是判断这句规则有问题,改成:

rewrite ^/school/joblist/(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html?(.+)$ “/school/index.php?c=job&city=$1&edu=$2&uptime=$3&pr=$4&job1=$5&job1_son=$6&job_post=$7&page=$8&keyword=%{QUERY_STRING} last”;

就是加了双引号:””

不然nginx以为这句就到前面就结束了。