2

If someone goes to mysite.com/notafile and it doesn't actually exist, I'd like to show mysite.com instead. However, I want to maintain the url in the user's browser, so it still shows mysite.com/notafile.

Is this possible?

1
  • Do you have a working Nginx configuration? Oct 31, 2019 at 17:56

1 Answer 1

0

When a file doesn't exits, web-server throws 404 Not Found error. What you are asking can be simply achieved by defining a custom 404 page which in your case can be an index.html page. Add this to your nginx config:

error_page 404 /index.html;

So in this case, the mysite.com/notafile URL will show the index.html page but also maintain the URL in the browser. However it is not a redirect, it simply displays index.html in place of error page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .