Defining a custom 404 for non-WordPress parts of site

Set the WordPress index.php as error handler in your .htaccess (if you are using Apache):

ErrorDocument 404 /wp/index.php

Make sure the path matches the path to the WordPress directory.