Hope this helps - Works well for me Drew jeromenelson at gmail dot com 19-Sep-2005 06:56 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! Angelina Bell 04-Aug-2005 11:55 Warning: $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME'] may not always be set correctly. Some web hosts implement php as a CGI in such a way that they can turn it on or off for each virtual domain. Several $_SERVER and $_ENV variable values may be incorrect for documents in subdirectory subdomains of these virtual domains. |