Nginx: unknown "location" directive

Here is my code (starting at 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.

+3
source share
1 answer

Make sure the location directive is located inside the server block:

http {
...
    server {
        ...
        location ...
    }
}
+13
source

Source: https://habr.com/ru/post/1776997/


All Articles