Fix wrongly guessed base_url on some webservers

Some of the webservers report more than they should in
*$_SERVER['SCRIPT_NAME']*, and this messes up the CodeIgniter base_url
guessing. Example, upon visiting http://url.com/Controller/Method, the
reported SCRIPT_NAME is /index.php/Controller/Method, and CI guesses the
base_url as: /index.php/Controller, which is wrong. This commit
addresses this issue, and looks for an "index.php" in SCRIPT_NAME, if
found, everything before index.php is part of the base_url, if not
found, the old method is used.