note 73151 added to function.parse-str

From: Date: Sun, 11 Feb 2007 00:20:34 +0000
Subject: note 73151 added to function.parse-str
Groups: php.notes 
Request: Send a blank email to php-notes+get-123230@lists.php.net to get a copy of this message
if you would like to get a nice url scheme with php/apache and and want to handle all requests in a central php script there's a simple solution/hack: create a .htaccess in your "basedir" where you've got your main script (in this example index.php) containing some lines like: "ErrorDocument 404 /index.php" inside index.php you can now do <?php $virtual_path = substr( $_SERVER['REQUEST_URI'], strlen( dirname( $_SERVER['PHP_SELF'] ) ) + 1 ); if( ($pos = strpos( $virtual_path, '?' )) !== false ) { parse_str( substr( $virtual_path, $pos + 1 ), $_GET ); $_REQUEST = array_merge( $_REQUEST, $_GET ); $virtual_path = substr( $virtual_path, 0, $pos ); } // some code checking for a valid location, etc... header( 'HTTP/1.1 200 OK' ); header( 'Content-Type: text/plain' ); echo $virtual_path."\n\n"; print_r( $_REQUEST ); ?> // guido 'lenix' boehm ---- Server IP: 212.124.37.9 Probable Submitter: 85.179.193.93 ---- Manual Page -- http://www.php.net/manual/en/function.parse-str.php Edit -- https://master.php.net/note/edit/73151 Del: integrated -- https://master.php.net/note/delete/73151/integrated Del: useless -- https://master.php.net/note/delete/73151/useless Del: bad code -- https://master.php.net/note/delete/73151/bad+code Del: spam -- https://master.php.net/note/delete/73151/spam Del: non-english -- https://master.php.net/note/delete/73151/non-english Del: in docs -- https://master.php.net/note/delete/73151/in+docs Del: other reasons-- https://master.php.net/note/delete/73151 Reject -- https://master.php.net/note/reject/73151 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123230) next »