When requesting a page that does not exist, your server configuration should already be set up so that the contents of the file "notfound.html" are displayed.
This text should be displayed at the originally requested URL, and the server will automatically deliver the correct "HTTP/1.1 404-Not Found" response in the HTTP header.
The 404 status code in the HTTP header signals that there is nothing at the URL. The page of error message text is merely a hint for the human.
It would be a bad idea to redirect to example.com/notfound.html and for the browser URL bar to show this URL, because the error message page would then be delivered with a "200 OK" HTTP response code. By it's very nature, the "not found" error page MUST be delivered with a "404" HTTP status code.