For my program I personally use dynamic URL spinning with PHP:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #Rewrite the URI if there is no file or folder
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #rewrite all to index.php
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

In PHP Then i break lower the URL in the various parts. For instance http://myhost/foo/bar returns foo bar. The issue I've is that if this program isn't situated within the root directory from the server, for instance http://myhost/this/is/a/folder/hereistheprogram/foo/bar, because then your script returnes this is a folder hereistheprogram foo bar. Are in possession of the issue which i can't differentiate between your folders and also the URL parameters.

Much less certain of the precise problem but..

Would you have constant 'foo' identifier utilized in the web addresses to recognize where you can break the string?

You should know what the road to the script file is. It can be done by either clearly proclaiming the road prefix or by identifying it instantly, for instance:

$basePath = dirname($_SERVER['SCRIPT_NAME']);

You'll be able to use that prefix and strip it in the request URI path:

if (substr($requestPath, 0, strlen($basePath)+1) === $basePath.'/') {
    $path = substr($requestPath, strlen($basePath));
} else {
    $path = $requestPath;
}

Incidentally: It might be better should you not pass the request URI path clearly for your index.php but retrieve it from $_SERVER['REQUEST_URI']:

$_SERVER['REQUEST_URI_PATH'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$_SERVER['REQUEST_URI_QUERY'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);

And also the corresponding mod_rewrite rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]