I set up 404 handler page in web.config, but it works ONLY when extension of URL is .aspx (or other which is handled by ASP.NET). I know I can setup static HTML page in webs
In IIS you can set a Custom Error for 404 errors and direct it to a URL in the site properties.
It shows a static html by default C:\WINDOWS\help\iisHelp\common\404b.htm
You can change it to a relative url on your site.