[Linux] 解决nginx: [emerg] directive "rewrite" is not terminated by ";"
解决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
最新文章
- 【spoj705】 Distinct Substrings
- SQL优化大全
- PAT乙级 1006. 换个格式输出整数 (15)
- echarts简单使用
- 关于JS的一点summary
- 数理方程:Laplace变换 &; 留数(更新中)
- Android 多种方式正确的加载图像,有效避免oom
- Web---文件上传-用apache的工具处理、打散目录、简单文件上传进度
- 2014年辛星解读Javascript之DOM之冒泡和捕获
- html5 音频和视频(audio And video)
- How to write a probeContentType() and Usage?
- Dynamics CRM2016 站点地图Bug之KnowledgeArticle不显示
- View requires API level 14 (current min is 8): <;GridLayout>;
- Rsync数据同步工具
- 第一次有人把5G讲的这么简单明了
- 使用PIP扩展BTARN
- 学以致用二---配置Centos7.2 基本环境
- 06 django的用户认证组件
- 微信小程序Wepy框架的三个事件交互($broadcast,$emit,$invoke)
- TypeError: not all arguments converted during string formatting
热门文章
- [b0043] python 归纳 (二八)_python测试使用快速上手
- read write方式打开PHYSICAL STANDBY,闪回和还原测试
- 《Linux/UNIX系统编程手册》第56章 SOCKET:介绍
- 运行springboot项目报错:Field userMapper in XX required a bean of type &#39;xx&#39; that could not be found.
- python xlwt写入excel操作
- vue预览本地图片
- mysql用户数据库只读权限提升全局权限
- class与class的继承
- AcWing&#160;13.&#160;找出数组中重复的数字
- AcWing&#160;28.&#160;在O(1)时间删除链表结点