Work on determination of "base_url" config item

* A little refactoring.
* Remove the basename only at the end, to avoid edge cases.