more reliable way of saving debug index file

fixes #1884
added schema parameter to createAbsoluteUrl() to force 'http' or 'https'

fixes #1585