nginx的location正则匹配问题

qq_23748135 2015-02-02 05:03:01
...全文
426 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_23748135 2015-02-02
  • 打赏
  • 举报
回复
引用 9 楼 wander_wind 的回复:
location ^/([A-D])([a-zA-Z0-9]+)/?$ {} 我在我这边的nginx上能启动了
你的对的,是我location下面的代码写错了 最后改成这样的了 "~/[A-D][a-zA-Z0-9]{10}$"
智商众筹 2015-02-02
  • 打赏
  • 举报
回复
location ^/([A-D])([a-zA-Z0-9]+)/?$ {} 我在我这边的nginx上能启动了
qq_23748135 2015-02-02
  • 打赏
  • 举报
回复
引用 7 楼 wander_wind 的回复:
missing ) in "^/([A-D])([a-zA-Z0-9]" 截断在大括号上了,估计是和后面的代码段大括号混淆,需要转义?或者把{10}直接换成+也可以 我没弄过这个...你看看有什么需要特殊处理的符号
也不行
智商众筹 2015-02-02
  • 打赏
  • 举报
回复
missing ) in "^/([A-D])([a-zA-Z0-9]" 截断在大括号上了,估计是和后面的代码段大括号混淆,需要转义?或者把{10}直接换成+也可以 我没弄过这个...你看看有什么需要特殊处理的符号
qq_23748135 2015-02-02
  • 打赏
  • 举报
回复
引用 4 楼 Novolee 的回复:
报错信息是什么? 贴出来。。。。
正在启动 nginx:nginx: [emerg] pcre_compile() failed: missing ) in "^/([A-D])([a-zA-Z0-9]"
qq_23748135 2015-02-02
  • 打赏
  • 举报
回复
引用 3 楼 wander_wind 的回复:
location ~ ^/([A-D])([a-zA-Z0-9]{10})/?$ 加个~就是正则匹配了
还是报错,启动不了 正在启动 nginx:nginx: [emerg] pcre_compile() failed: missing ) in "^/([A-D])([a-zA-Z0-9]"
李睿_Lee 2015-02-02
  • 打赏
  • 举报
回复
报错信息是什么? 贴出来。。。。
智商众筹 2015-02-02
  • 打赏
  • 举报
回复
location ~ ^/([A-D])([a-zA-Z0-9]{10})/?$ 加个~就是正则匹配了
qq_23748135 2015-02-02
  • 打赏
  • 举报
回复
引用 1 楼 wander_wind 的回复:
rewrite ^/([A-D])([a-zA-Z0-9]{10})/?$ /index.php?a=$1&b=$2 last;
是在location 里匹配,匹配到了做转发的 下面这个报错了,启动不了
	location ^/([A-D])([a-zA-Z0-9]{10})/?$ {
		proxy_pass http://127.0.0.1:88/;
		proxy_redirect off;
		proxy_set_header Host localhost2;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Referer $http_referer;
		proxy_set_header Cookie $http_cookie;
		proxy_connect_timeout 60;
		proxy_read_timeout 600;
		proxy_send_timeout 600;
	}
智商众筹 2015-02-02
  • 打赏
  • 举报
回复
rewrite ^/([A-D])([a-zA-Z0-9]{10})/?$ /index.php?a=$1&b=$2 last;

21,873

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧