--- mdocml-1.14.1/cgi.c.orig 2017-02-21 01:25:20.000000000 +0100 +++ mdocml-1.14.1/cgi.c 2017-02-25 16:28:06.751637253 +0100 @@ -562,9 +562,13 @@ * If we have just one result, then jump there now * without any delay. */ + const char *scheme = "http", *https; + if ((https = getenv("HTTPS")) != NULL && + strcmp(https, "on") == 0) + scheme = "https"; printf("Status: 303 See Other\r\n"); - printf("Location: http://%s/%s%s%s/%s", - HTTP_HOST, scriptname, + printf("Location: %s://%s/%s%s%s/%s", + scheme, HTTP_HOST, scriptname, *scriptname == '\0' ? "" : "/", req->q.manpath, r[0].file); printf("\r\n"