解决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

最新文章

  1. 【spoj705】 Distinct Substrings
  2. SQL优化大全
  3. PAT乙级 1006. 换个格式输出整数 (15)
  4. echarts简单使用
  5. 关于JS的一点summary
  6. 数理方程:Laplace变换 & 留数(更新中)
  7. Android 多种方式正确的加载图像,有效避免oom
  8. Web---文件上传-用apache的工具处理、打散目录、简单文件上传进度
  9. 2014年辛星解读Javascript之DOM之冒泡和捕获
  10. html5 音频和视频(audio And video)
  11. How to write a probeContentType() and Usage?
  12. Dynamics CRM2016 站点地图Bug之KnowledgeArticle不显示
  13. View requires API level 14 (current min is 8): <GridLayout>
  14. Rsync数据同步工具
  15. 第一次有人把5G讲的这么简单明了
  16. 使用PIP扩展BTARN
  17. 学以致用二---配置Centos7.2 基本环境
  18. 06 django的用户认证组件
  19. 微信小程序Wepy框架的三个事件交互($broadcast,$emit,$invoke)
  20. TypeError: not all arguments converted during string formatting

热门文章

  1. [b0043] python 归纳 (二八)_python测试使用快速上手
  2. read write方式打开PHYSICAL STANDBY,闪回和还原测试
  3. 《Linux/UNIX系统编程手册》第56章 SOCKET:介绍
  4. 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.
  5. python xlwt写入excel操作
  6. vue预览本地图片
  7. mysql用户数据库只读权限提升全局权限
  8. class与class的继承
  9. AcWing 13. 找出数组中重复的数字
  10. AcWing 28. 在O(1)时间删除链表结点