nginx : unknown directive “location”

2019-04-11 00:35发布

Here is my code (starting with line 35):

location /

{

  index index.php;
  root  /home/body;

  if ($request_filename !~ (js|css|images|robots\.txt|index\.php.*) ) {
    rewrite ^/(.*)$ /index.php/$1 last;
  }
}

Here is the error:

[emerg]: unknown directive "location" in /opt/nginx/conf/nginx.conf:35

Can anyone help how to fix this? Thanks in advance.

标签: nginx
1条回答
贼婆χ
2楼-- · 2019-04-11 00:48

Ensure that location directive located inside of server block:

http {
...
    server {
        ...
        location ...
    }
}
查看更多
登录 后发表回答