Scrapy Spider
Scrapy Spider

Reputation: 13

Nginx not redirect all requests to index.html

I am trying to redirect all requests to index.html on Nginx but it's not redirecting.

Working -> https://www.example.com/reviews

Not Working -> https://www.example.com/reviews/

in 2nd URL if you see in last due to "/" Slash it's not working.

I am using the following settings in Nginx settings

location / {
  try_files $uri /index.html;
}

Upvotes: 1

Views: 2476

Answers (1)

Coder-256
Coder-256

Reputation: 5618

Nginx considers directories (URLs with a trailing slash) separately from normal files. Try this instead:

location / {
  try_files $uri $uri/ /index.html;
}

Upvotes: 1

Related Questions