If I have a user accessing my site for example: www.example.com/testpage.html, is there any way to grab the "testpage.html" as a string if the testpage.html doesn't exist? (I want to make custom 404 error messages..Basically I want when the user goes to a page that doesnt exist, say "This page [pagename] doesnt exist" and display a search result with the pagename as the query.)
closed as off topic by random♦ Jan 31 '13 at 5:19
Questions on Super User are expected to relate to computer software or computer hardware within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.
Generally if you want to do anything useful with dynamic content, you're going to need some sort of interpreted language to provide the logic. As you did not specify, I assume you'll be using PHP.
In the case of PHP, you have access to the $_SERVER superglobal which, among other bits, exposes REQUEST_URI (e.g. $_SERVER['REQUEST_URI']) which is exactly what you are looking for. You can then build some logic in your PHP script around this variable to do actions based on specific matched URIs.
You could, of course, also get fancy with regular expressions, case statements, etc.
It sounds like your real question is "How do I make a custom 404 page", yes? That's going to be web server dependent.