That is a normal result of running PHP as CGI instead of mod_PHP. There are a couple of workarounds I can suggest; which works best for you depends a lot on your script.
1) Add this following assignment to your script:
$SERVER['SCRIPTNAME'] = $SERVER['SCRIPTURL'];
** or **
2) Run the script under mod_php, by inserting:
“AddType application/x-httpd-php .foo” or
“AddHandler application/x-httpd-php .php“ in your .htaccess file.
You can get an idea of other potential workarounds by running creating a file called phpinfo.php, in a web-accessible directory, containing the following:
and then browsing to that file and inspecting the output to see what other environment variables your script uses that might be affected. You can handle them the same way by just reassigning the value to one that has the value you need when running PHP-CGI. Good Luck, and Merry Christmas!