You can use this code to redirect all requests to a single file:
RewriteEngine on RewriteRule ^.*?(\?.*)?$ myfile.php$1
Please note that all requests (including stylesheets, images, ...) will also be redirected. Of course, there are other possibilities (rules), but this is the one I use, and it will contain the correct query string. If you do not need it, you can use
RewriteEngine on RewriteRule ^.*?$ myfile.php
This is a common technique, as bots and even users see only their URL, and not how it is processed internally. Server performance is not a problem at all.
Since you are redirecting all urls to a single php file, there is no longer a 404 page because it is cached by your .php file. Therefore, make sure that you handle incorrect URLs incorrectly.
source share