@matheusbsbs / matheus-bagliano / commits / 0dbf027ad2
Fork 0

gitweb: webserver config for PATH_INFO

Document some possible Apache configurations when the path_info feature is enabled in gitweb. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Giuseppe Bilotta committed Jan 31, 2009 at 02:31 UTC 0dbf027ad2fc946cb63330146560962fa5d43d2d
1 file changed +76
gitweb/README
+76
@@ -322,6 +322,82 @@ something like the following in your gitweb.conf (or gitweb_config.perl) file:
322 $home_link = "/";
323
324
325 +PATH_INFO usage
326 +-----------------------
327 +If you enable PATH_INFO usage in gitweb by putting
328 +
329 + $feature{'pathinfo'}{'default'} = [1];
330 +
331 +in your gitweb.conf, it is possible to set up your server so that it
332 +consumes and produces URLs in the form
333 +
334 +http://git.example.com/project.git/shortlog/sometag
335 +
336 +by using a configuration such as the following, that assumes that
337 +/var/www/gitweb is the DocumentRoot of your webserver, and that it
338 +contains the gitweb.cgi script and complementary static files
339 +(stylesheet, favicon):
340 +
341 +<VirtualHost *:80>
342 + ServerAlias git.example.com
343 +
344 + DocumentRoot /var/www/gitweb
345 +
346 + <Directory /var/www/gitweb>
347 + Options ExecCGI
348 + AddHandler cgi-script cgi
349 +
350 + DirectoryIndex gitweb.cgi
351 +
352 + RewriteEngine On
353 + RewriteCond %{REQUEST_FILENAME} !-f
354 + RewriteCond %{REQUEST_FILENAME} !-d
355 + RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
356 + </Directory>
357 +</VirtualHost>
358 +
359 +The rewrite rule guarantees that existing static files will be properly
360 +served, whereas any other URL will be passed to gitweb as PATH_INFO
361 +parameter.
362 +
363 +Notice that in this case you don't need special settings for
364 +@stylesheets, $my_uri and $home_link, but you lose "dumb client" access
365 +to your project .git dirs. A possible workaround for the latter is the
366 +following: in your project root dir (e.g. /pub/git) have the projects
367 +named without a .git extension (e.g. /pub/git/project instead of
368 +/pub/git/project.git) and configure Apache as follows:
369 +
370 +<VirtualHost *:80>
371 + ServerAlias git.example.com
372 +
373 + DocumentRoot /var/www/gitweb
374 +
375 + AliasMatch ^(/.*?)(\.git)(/.*)? /pub/git$1$3
376 + <Directory /var/www/gitweb>
377 + Options ExecCGI
378 + AddHandler cgi-script cgi
379 +
380 + DirectoryIndex gitweb.cgi
381 +
382 + RewriteEngine On
383 + RewriteCond %{REQUEST_FILENAME} !-f
384 + RewriteCond %{REQUEST_FILENAME} !-d
385 + RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
386 + </Directory>
387 +</VirtualHost>
388 +
389 +The additional AliasMatch makes it so that
390 +
391 +http://git.example.com/project.git
392 +
393 +will give raw access to the project's git dir (so that the project can
394 +be cloned), while
395 +
396 +http://git.example.com/project
397 +
398 +will provide human-friendly gitweb access.
399 +
400 +
401 Originally written by:
402 Kay Sievers <kay.sievers@vrfy.org>
403