In the event of an HTTP 404 error ("Page not found") this PHP snippet will render a site search form, but will take keywords from the user's erroneous URL and pre-populate.
Create a new node (node/add/page), and ensure you can enter PHP code in your page body (check input filters).
Insert the following code into the body of your new page: