fixed SCRIPT_NAME handling. take 2