Nginx伪静态:[Emerg] Directive “Rewrite” Is Not Terminated By 错误

源地址:http://blog.is36.com/archives/50/

 

遭遇问题:directive “rewrite” is not terminated by “;”

用vi编辑器编辑完nginx.conf文件后保存,在shell下执行命令/usr/local/web/nginx/sbin/nginx -t用以检查nginx.conf配置文件是否正确(假设nginx被编译到/usr/local/web/nginx/)
正确的话:

[root@localhost]# /usr/local/web/nginx/sbin/nginx -t
the configuration file /usr/local/web/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/web/nginx/conf/nginx.conf test is successful

如果出现如下问题:directive “rewrite” is not terminated by “;”

[root@localhost]# /usr/local/web/nginx/sbin/nginx -t
[emerg]: directive “rewrite” is not terminated by “;” in /usr/local/web/nginx/conf/nginx.conf:160
configuration file /usr/local/web/nginx/conf/nginx.conf test failed

处理方法:将重新后的url用双引号引起来!

出错:rewrite ^/date/([0-9]{6})/?([0-9]+)?/?$ /index.php?action=article&setdate=$1&page=$2 last;
正确:rewrite “^/date/([0-9]{6})/?([0-9]+)?/?$” /index.php?action=article&setdate=$1&page=$2 last;

看着那句directive “rewrite” is not terminated by “;”还以为是没;呢!
参考资料:http://developmentcase.com/2009/04/17/nginx-rewrite-and-directive-rewrite-is-not-terminated-by/

订阅评论
提醒
guest的头像

0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x