Nginx: Unknown Directive “Location”

This is my code (from line 35):

location /

{

index index.php;
root /home/body;

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

This is an error :

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

Anyone can help This problem? Thanks in advance.

Make sure to locate the location directive within the server block:

< p>

http {
...
server {
...
location ...
}
}< /pre>

This is my code (from line 35):

location /

{

index index.php;
root /home/body;

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

This is the error:

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

Anyone Can you help solve this problem? Thanks in advance.

Make sure to locate the location instruction in the server block:

http {< br />...
server {
...
location ...
}
}

Leave a Comment

Your email address will not be published.