Improved getCurrentUrl() implementation

The prior implementation did not handle requests from URLs
except those that existed at the root of the server, and it did not
allow for applications that don't use URL rewriting to ignore 'index.php'
or whatever the main execution script is.

This commit fixes those issues.