Note Submitter: jeromenelson at gmail dot com
----
You can take advantage of 404 error to an usable redirection using REQUEST_URI ...
For example the following program can retrieve the information for the 'search_string', for a given URI: http://servername/profiles/search_string, even though there's no such path.
Do the following steps..
Step 1: Edit Apache config: set
ErrorDocument 404 "/missing.php"
Step 2: Write the missing.php as follows ...
<?
$mainPath = "/profiles/"; // Example: http://servername/profiles/search_string
$mpLength = strlen( $mainPath );
$request_uri = $_SERVER['REQUEST_URI'];
if ( $mainPath != substr($request_uri,0,$mpLength) ) { // Check if the given URI is valid
echo "404 Page Not Found !";
exit();
}
$name = substr ($request_uri , $mpLength ) ; // Extract the string to be searched
echo "You have searched for the profile of Mr. $name";
/** Here you can write the code to retrieve and display
the $name's information from the database
*/
?>
Step 3: Now try http://servername/profiles/Jerry
(of course, there shouldn't be a file/folder in the server like "DOCROOT/profiles/Jerry" )
output: You have searched for the profile of Mr. Jerry
God Bless You!
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.