解决nginx: [emerg] directive "rewrite" is not terminated by ";"
nginx的rewite规则有时候没注意会报这个错误,原因是规则中存在{}会被认为是规则结尾报错,使用""双引号把规则包起来可以避免这个错误
还有就是nginx中的规则中/斜杠不必要反斜杠转义\/,自动会认识的

例如:
rewrite "^\/rny\/webface\/mailApps\/(.*)(\/\d{6,})(.*)$" /webface/mailapps/dev/$1$3

.*和.*?的区别:
.*?是非贪婪的,匹配到第一个/就停了
[root@localhost riadev]# echo "/rny/webface/mailApps/xxx/dfdffd/123456_abc.js"|grep -oP "^/rny/webface/mailApps/(.*?)/"
/rny/webface/mailApps/xxx/

.*是贪婪的,匹配到了最后一个/
[root@localhost riadev]# echo "/rny/webface/mailApps/xxx/dfdffd/123456_abc.js"|grep -oP "^/rny/webface/mailApps/(.*)/"
/rny/webface/mailApps/xxx/dfdffd/

\d{6,}这个的意思是最少6个数字,超过的也能匹配到,少的匹配不到
grep是不能捕获()中的内容,在nginx中后面的$就是可以捕获到
[root@localhost riadev]# echo "/rny/webface/mailApps/xxx/dfdffd/123456abc.js"|grep -oP "^/rny/webface/mailApps/(.*)/(\d{6,})(.*)"
/rny/webface/mailApps/xxx/dfdffd/123456abc.js
这个时候的$1和$3分别是xxx/dfdffd 和 abc.js

rewrite "^\/rny\/webface\/mailApps\/(.*)(\/\d{6,})(.*)$" /webface/mailapps/dev/$1$3
会把/rny/webface/mailApps/xxx/dfdffd/123456abc.js 匹配到 /webface/mailapps/dev/xxx/dfdffd/abc.js

[Linux] 解决nginx: [emerg] directive "rewrite" is not terminated by ";"的更多相关文章

  1. nginx重写规则报nginx: [emerg] directive "rewrite" is not terminated by ";"

    对于下面的重写规则 rewrite ^/gongying/([\d]{8})_([\d]+).html$ /index.php?app=support&act=view&pts=$1& ...

  2. nginx: [emerg] directive "upstream" has no opening "{" in /application/nginx-1.6.3/conf/nginx.conf:13 ...

    修改nginx.conf配置文件时,报以下错误: [root@bqh-lb- nginx]# vim conf/nginx.conf [root@bqh-lb- nginx]# sbin/nginx ...

  3. Nginx 学习笔记(七)如何解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

    出现:nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) 错误,有以下两种情况 1.80端口被占用 2.ipv4端 ...

  4. nginx: [emerg] directive "location" has no opening "{" in /usr/local/nginx//conf/nginx.conf:75

    1.报错:[emerg]directive "location" has no opening "{" in ..... 解决方法: 由于对应行或者附近行的“{ ...

  5. [运维] 如何解决 nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

    环境: 虚拟机 linux centos 7 64 当时正在配置 nginx , 由于解压后的 nginx 默认安装位置是在 /usr/local/ 目录下, 而这个目录是 root 用户才有权限操作 ...

  6. 解决nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

    nginx先监听了ipv4的80端口之后又监听了ipv6的80端口,于是就重复占用了.更加坑人的是你去看了端口占用它又把80端口释放了,是不是很囧. 解决方案是编辑nginx的配置文件 修改这一段:

  7. nginx:[emerg]unknown directive "ssl"

    nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/nginx.conf:102 到解压的nginx目录 ...

  8. 错误提示 nginx: [emerg] unknown directive "gzip_static"

    1.检查nginx配置文件错误提示如下: [root@server nginx]# /applications/nginx/sbin/nginx -t -c /applications/nginx/n ...

  9. nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:57

    /************************************************************************************************ * ...

随机推荐

  1. docker tomcat8 mysql8部署常见错误

    出现docker: out of memory bug ,内存溢出 解决方法: free -mh 应该看一下内存 内存优化/买内存 出现java.util.zip.ZipException: erro ...

  2. 更改 undo_retention 时,Lob retention 不更改 (Doc ID 563470.1)

    Lob retention not changing when undo_retention is changed (Doc ID 563470.1) APPLIES TO: Oracle Datab ...

  3. Linux IO协议栈

    图片来源自网络,保持更新:更多内容请关注 cnblogs.com/xuyaowen 参考链接: https://zhuanlan.zhihu.com/p/39721251 http://blog.yu ...

  4. Python3+Requests+Excel完整接口自动化框架

    框架整体使用Python3+Requests+Excel:包含对实时token的获取 框架结构图 1.------base -------runmethond.py runmethond:对不同的请求 ...

  5. poj 3253 Fence Repair 贪心 最小堆 题解《挑战程序设计竞赛》

    地址 http://poj.org/problem?id=3253 题解 本题是<挑战程序设计>一书的例题 根据树中描述 所有切割的代价 可以形成一颗二叉树 而最后的代价总和是与子节点和深 ...

  6. 03. Go 语言容器

    Go语言容器(container) 变量在一定程度上能满足函数及代码要求.如果编写一些复杂算法.结构和逻辑,就需要更复杂的类型来实现.这类复杂类型一般情况下具有各种形式的存储和处理数据的功能,将它们称 ...

  7. Azure Sphere Development Environment Setup

    1. Visual Studio 目前,Visual Studio 2017/2019支持Azure Sphere开发,后续,微软会加入Visual Studio Code的支持.以Visual St ...

  8. 打印从1到最大的n

    题目:输入数字n,按顺序打印出从1到最大的n位十进制数.比如输入3,则打印出1.2.3一直到最大的3位数999 需考虑大数问题 #-*-coding:utf-8-*- class print_N: d ...

  9. 【VM配置】配置主机名称、网卡和yum源配置

    一,.配置主机名 为了对主机能进行分区,除了要有ip地址外还需要主机名,主机之间可以通过这个类似域名的名称来相互访问.linux系统中主机名配置文件一般在/etc/hostname文件中.另外我们也可 ...

  10. app自动化测试初体验

    一.appium环境开启 1.开启MUMU模拟器/真机(真机需要开启“USB开发调试模式”),使用命令行adb devices检查设备是否正常连接 2.开启appium 双击运行appium应用 正常 ...