76e6620f0bfc2240b45505446f5cba41b9b72817
max
  Thu Mar 6 03:39:36 2014 -0800
Allow special value HTTPHOST for central.domain and wiki.host, so aserver can be reached under multiple names. Might be a good default
value for our example hg.conf? refs #11957

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 2cef778..5e97336 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3191,42 +3191,52 @@
 struct slName *hSplitTableNames(char *db, char *rootName)
 /* Return a list of all split tables for rootName, or of just rootName if not
  * split, or NULL if no such tables exist. */
 {
 struct hash *hash = NULL;
 struct hashEl *hel = NULL;
 
 hash = tableListGetDbHash(db);
 hel = hashLookup(hash, rootName);
 if (hel == NULL)
     return NULL;
 else
     return slNameCloneList((struct slName *)(hel->val));
 }
 
-boolean hHostHasPrefix(char *prefix)
-/* Return TRUE if this is running on web-server with host name prefix */
+char* hHttpHost()
+/* return http host from apache or hostname if run from command line  */
 {
 char host[256];
-if (prefix == NULL)
-    return FALSE;
 
 char *httpHost = getenv("HTTP_HOST");
+
 if (httpHost == NULL && !gethostname(host, sizeof(host)))
     // make sure this works when CGIs are run from the command line.
     httpHost = host;
 
+return httpHost;
+}
+
+
+boolean hHostHasPrefix(char *prefix)
+/* Return TRUE if this is running on web-server with host name prefix */
+{
+if (prefix == NULL)
+    return FALSE;
+
+char *httpHost = hHttpHost();
 if (httpHost == NULL)
     return FALSE;
 
 return startsWith(prefix, httpHost);
 }
 
 boolean hIsPrivateHost()
 /* Return TRUE if this is running on private (development) web-server.
  * This was originally genome-test as well as hgwdev, however genome-test
  * may be repurposed to direct users to the preview site instead of development site. */
 {
 return hHostHasPrefix("hgwdev") || hHostHasPrefix("genome-test");  // FIXME: If genome-test
 }
 
 boolean hIsBetaHost()