V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
silenceeeee
V2EX  ›  NGINX

请求一个 nginx 配置问题

  •  
  •   silenceeeee · 2016-10-10 13:01:49 +08:00 · 2096 次点击
    这是一个创建于 2759 天前的主题,其中的信息可能已经有所发展或是发生改变。
    location ~ ^/admin{
    rewrite ...;
    }
    这样用 nginx -t 检测的时候不会报错.

    location ~ \.php${
    ...
    }
    这样会报错: nginx: [emerg] directive "location" has no opening "{"

    1. 两个"{"之前都没有加空格 .为什么一个报错.一个不报错呢
    2. "{"前面到底要不要加空格?
    2 条回复    2016-10-10 13:25:51 +08:00
    rrfeng
        1
    rrfeng  
       2016-10-10 13:07:26 +08:00
    1. $ 是变量标识,比如 $http_host 这样,所以连在一起的时候就解析错误了(被认为是 `${` 变量)。
    2. 当然加空格
    silenceeeee
        2
    silenceeeee  
    OP
       2016-10-10 13:25:51 +08:00
    @rrfeng 谢谢 明白了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5280 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 406ms · UTC 08:06 · PVG 16:06 · LAX 01:06 · JFK 04:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.