Reusable server url

Improve the re-usability of the addQueryArg() method

- Support SSL protocol
- Make the serverUrl code re-usable
No, if the code is in the domain root 'myserver.com/' on a Windows server, `dirname($path)` returns '\' which in turn will give problems when using that in the url which is passed on in serialized/json format leading to urls like: `http://myserver.commypath?query=test`

@see http://php.net/manual/en/function.dirname.php