Fix #2976
[ci skip] Fix #2972
Refactoring in Config->__construct()

Put the $_SERVER['HTTP_HOST'] fallback in a more logical place.
Robuster determination of "base_url" config item

Remove the basename only at the end, to avoid edge cases.
Different method for determining "base_url"

Better performance by not using regex.
Remove test that has become unfit
Fix #2970
Fixed according to comment.
Removed tabs.
Removed tab on empty line too.
Remove spaces around concatenations

per request
Merge pull request #2982 from aanbar/migration-fix

Fix #2970
Yet another method for determining "base_url"

This one is great because we don't have to deal with the special cases:
* in Windows, dirname('/foo/index.php') gives "/foo", but dirname('/index.php') gives "\" instead of "/"
* dirname() doesn't include the trailing slash, with the expection of "/" (root)

props @narfbg
Add test for "base_url" determination on server root
Discard the unwanted changes
Merge pull request #2981 from vlakoff/base_url

Work on determination of "base_url" config item
Optimize #2982
fixes warnings
Merge pull request #2983 from iBotPeaches/develop

fixes warnings
[ci skip] Document 'first_url' Pagination option (supersedes PR #2992)