gtalarico
gtalarico

Reputation: 4689

Nginx try_files fallback path returns 404 when using url query args

Goal

I have a folder /assets which contains files like index.hml, css/*, js/*, etc.

Here is what I want to accomplish:

I also need query params ($args) to be passed through

Here is my enginx partial configuration:

location / {
  root /assets;
  try_files $uri $uri/index.html$is_args$args =404;
}

With this settings I get the following results:

Question

What do I have to change to have domain.com/?q=x to return the same response as domain.com/index.html?q=x instead of not 404

Upvotes: 1

Views: 2986

Answers (1)

gtalarico
gtalarico

Reputation: 4689

The proposed answer by @richard-smith solved it

location / {
  root /assets;
   index index.html;
   try_files $uri $uri/ =404;

Upvotes: 1

Related Questions