Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to display static HTML content using an Apache 2 webserver while also having a Mercurial repository under the same URL. E.g. under there should be the project HTML available if browsed with a normal web-browser, but it should be possible to clone the projects Mercurial repository using hg clone It is basically what has. I think this might be possible to achieve by configuring Apache to use the hgweb.cgi script only for Mercurial requests and not for normal HTML GET request. However, I don't now which requests Mercurial uses (hopefully not GET) and how to configure Apache accordantly.

A little bit more background:
In need this for multiple repositories / projects (currently ~2400). So far I tried hgweb as explained in Publishing Repositories which works good for the web view of the repository but doesn't allow me to show any other information beside author, name and description (from .hg/hgrc [web] section). The variable substitution in hgweb is very limited and so it doesn't allow to provide arbitrary variables. I know I could simply have the static HTML pages and hgweb under different URLs, but this is not meet the constrains given to me.

share|improve this question

To understand what kind of request send mercurial - we have perfect tcpdump.

I start tcpdump, do hg clone

and see that hg do GET request /hg?cmd=capabilities , /hg?cmd=getbundle , /hg?cmd=batch

I think , you can collect all needed requests for hg, and configure apache (or nginx, or some other proxy) forward such requests to hgweb.cgi

share|improve this answer
I was actually looking for a more direct solution which is already tested. But you seem to hit something: After looking at the HG Python code and searching a little more using the new found keywords it turns out that all commands really use cmd as part of the HTTP query string. I hacked something together based on RewriteRule and ScriptAlias to only have these requests forwarded to the CGI script but have the others handled by Apache directly. I'm still hoping someone posts a more "official" way to do it. Thanks! – Martin Scharrer Oct 10 '11 at 7:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.