After about four days of experiments, I got a slightly different solution than I expected from him. I simply deleted all the actual manipulations with the URL into the index.php file and sent all the requests there. Here is my (much cleaner) .htaccess file:
Options +FollowSymlinks RewriteEngine On RewriteCond %{QUERY_STRING} (.*) RewriteRule (.*) index.php?path=$1 [QSA,L]
and here is the code block that I used to parse the entered URL:
preg_match_all ('| / ([A-Za-z0-9] +) ((?! /) [A-Za-z0-9 -.] *) |', $ _GET ['path'], $ matches) ;
// Remove all '$_GET' parameters from the actual $_GET superglobal: foreach($matches[0] as $k => $v) { $search = '/' . substr($v, 1); $_GET['path'] = str_replace($search, '', $_GET['path'], $count); } // Add $_GET params to URL args for ($i = 0; $i < count($matches[1]); $i++) { self::$get_arguments[$matches[1][$i]] = $matches[2][$i]; } // Retrieve all 'cmd' properties from the URL and create an array with them: preg_match_all('~(cmd[0-9]*)/(.+?)(?=(?:cmd)|(?:\z))~', $_GET['path'], $matches); if (isset($matches[1][0])) { return self::$url_arguments = array_combine($matches[1], $matches[2]);
At a URL like this:
http://localhost/frame_with_cms/frame/www/cmd/one/cmd2/two/cmd3/three/cmd4/four/getparam_valuepart1_valuepart2/cmd5/five/
It successfully creates these separate arrays, which I then use to process requests:
Array ( [getparam] => valuepart1_valuepart2 ) Array ( [cmd] => one/ [cmd2] => two/ [cmd3] => three/ [cmd4] => four/ [cmd5] => five/ )
Thanks to everyone who took the time to read and respond.
source share