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?
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?
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.