def rewrite_to_secure_url(url, secure_base=None):
    """
    Rewrite URL to a Secure URL

    @param url URL to be rewritten to a secure URL.
    @param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL).
    """
    if secure_base is None:
        secure_base = cfg.get('CFG_SITE_SECURE_URL')
    url_parts = list(urlparse(url))
    url_secure_parts = urlparse(secure_base)
    url_parts[0] = url_secure_parts[0]
    url_parts[1] = url_secure_parts[1]
    return urlunparse(url_parts)
Rewrite URL to a Secure URL

    @param url URL to be rewritten to a secure URL.
    @param secure_base: Base URL of secure site (defaults to CFG_SITE_SECURE_URL).