3

i want to serve file on nginx server here's the case below

serve location /home/ubuntu/username/fileName
eg1 /home/ubuntu/john/d1.txt
eg2 /home/ubuntu/john/d2.txt
eg3 /home/ubuntu/kiddo/d3.txt

it is not accessable using.

location ~ /home/ubuntu/(?<user>.+)/(?<file>.+)$ {
            root /home/ubuntu/$user/$file;
}

nginx rules on stackoverflow

patabhu
  • 51
  • 3

1 Answers1

1

Could you please try following, based on your shown samples. Please make sure to clear your browser cache before testing your URLs.

location ~ /home/ubuntu/([^/]*)/([^/]*)/?$ {
            root /home/ubuntu/$1/$2;
}
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93