nginx: [emerg] directive “rewrite” is not terminated by “;”错误
来源:互联网 发布:联想固态硬盘优化软件 编辑:程序博客网 时间:2024/06/06 10:54
错误提示:
[root@Rekfan sbin]# ./nginx -t
nginx: [emerg] directive "rewrite" is not by ";" in /usr/local/nginx/vhost/Rekfan.conf:24
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@Rekfan sbin]# ./nginx -t
nginx: [emerg] directive "rewrite" is not terminated by ";" in /usr/local/nginx/vhost/Rekfan.conf:25
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
You have new mail in /var/spool/mail/root
查看伪静态规则 发现没有问题,最后是以last;结束的,但仍然会报错。
rewrite ^(.*)/list-([0-9]{1,}).html$ $1/index.php?lid=$2 last;
rewrite ^(.*)/file-([0-9]{1,}).html$ $1/index.php?fid=$2 last;
rewrite ^(.*)/article-([0-9]{1,}).html$ $1/index.php?aid=$2 last;
错误原因:
后来调试发现,这是由于规则里有大括号“{ }”的符号,Nginx误以为这是规则的结尾,产生错误。
解决方法:
因此,为避免这种情况的发生,需要用双引号把伪静态规则给标识出来,就可以了。
更改为如下规则后正常
rewrite "^(.*)/list-([0-9]{1,}).html$" $1/index.php?lid=$2 last;
rewrite "^(.*)/file-([0-9]{1,}).html$" $1/index.php?fid=$2 last;
rewrite "^(.*)/article-([0-9]{1,}).html$" $1/index.php?aid=$2 last;
[root@Rekfan sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
0 0
- nginx: [emerg] directive “rewrite” is not terminated by “;”错误
- nginx配置rewrite时报directive “rewrite” is not terminated by “;”
- nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:45
- 【Nginx】nginx中重写rewrite的语法错误[emerg] unknown directive
- nginx中重写rewrite的语法错误[emerg] unknown directive
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) 错误
- nginx:[emerg]unknown directive "ssl"
- nginx中重写rewrite的语法错误[emerg] unknown directive “if($host!=”
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) 报错
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) 报错
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) 报错
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
- nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
- nginx 启动错误"nginx: [emerg] host not found in upstream "解决方案
- nginx: [emerg] getpwnam(“www”) failed错误
- Nginx错误:[emerg] getpwnam(“www”) failed
- 【LB】迷宫寻路——栈与迭代的应用
- 如何反编译apk文件得到源码和XML文件
- 函数指针的作用
- Fibonacci查找算法
- Sun-JNI文档系列之五——第四章:成员和方法
- nginx: [emerg] directive “rewrite” is not terminated by “;”错误
- 合并两个排序的链表
- #每日coding#
- 【OpenCV入门教程之十】 形态学图像处理(一):膨胀与腐蚀
- C++primer plus第六版课后编程题答案10.8
- Open Inventor-Coin3D开发环境
- MFC中时间显示
- 2014-04-14 找出回文字串(穷举法)
- 【LB】C语言实现贪吃蛇