4

My root directory

/web/app/src

In this directory I have 2 directories /js/ and /assets/ and one file index.html

This is what I need to achieve:

Any request to /js/ or /assets/ or /index.html just serve files from root directory For example myapp.com/js/app.js servers app.js from /web/app/src/js/ directory Same with requests to /assets/

But all other requests, any other uri should result in serving index.html

For example

myapp.com/bla/bla/q?param=x Should serve index.html from web root directory

All rewrites should be internal, no http 301 redirects.

1

1 Answer 1

15

Sir, please try below code. :)

server {
   ...
   root /web/app/src;
   ...
   location / {
      try_files $uri $uri/ /index.html;
   }
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.