Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx return file for path

Tags:

nginx

I want Nginx to return r.json file for path example.com/r/ What I tried:

location /r/ {
    alias /home/user/media/json/r.json;
}

But all that didn't work. I've got 500 with message:

/home/user/media/json/r.jsonindex.html is not a directory

like image 573
shaihulud Avatar asked Dec 16 '15 16:12

shaihulud


2 Answers

  location = /r/ {
    try_files r.json =404;
  }
like image 29
Atish Narlawar Avatar answered Sep 19 '22 15:09

Atish Narlawar


Use the index directive to name r.json as the default filename within that location:

location /r/ {
    index r.json;
    alias /home/user/media/json/;
}
like image 57
Richard Smith Avatar answered Sep 18 '22 15:09

Richard Smith