Getting redirects to work in Apache for Gitweb
April 22, 2009 11:12 PM Subscribe
I've setup Gitweb as a sub-folder off my primary domain and have pathinfo enabled so that I get nice looking URLs. Everything works fine if I type http://my.domain.com/gitweb/ but if I miss the trailing slash I get 404 errors. Seems like a simple problem, but so far nothing's working!
Here's my gitweb.conf:
$feature{'blame'}{'default'} = [undef];
$feature{'pickaxe'}{'default'} = [undef];
$feature{'search'}{'default'} = [undef];
$feature{'grep'}{'default'} = 1;
$feature{'snapshot'}{'default'} = ['tgz', 'gzip', 'zip'];
$feature{'snapshot'}{'override'} = 1;
$projects_list = "/var/git/gitosis/projects.list";
$export_ok = "";
$strict_export = "true";
$site_name = "The Average Geek's Git Repo";
$fallback_encoding = 'utf-8';
@stylesheets = ("gitweb.css");
$projects_list_description_width = 50;
# This lets it make the URLs you see in the header
@git_base_url_list = ( 'git://my.domain.com');
# Title
$home_link_str = 'The Average Geek';
# nicer-looking URLs
$feature{'pathinfo'}{'default'} = [1];
$my_uri = "http://my.domain.com/gitweb/gitweb.cgi";
$home_link = "http://my.domain.com/gitweb/";
Onto my httpd.conf:
Alias /gitweb/ /var/www/gitweb/
RewriteEngine On
RewriteRule ^gitweb$ gitweb/ [R]
<Directory "/var/www/gitweb/">
AllowOverride AuthConfig
Options +ExecCGI +Indexes
Order allow,deny
Allow from all
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG "/etc/gitweb.conf"
AddHandler cgi-script .cgi
RewriteEngine On
RewriteBase /gitweb/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>
The Rewrite conditions inside the Directory stanza are "recommended" by the gitweb README if the pathinfo option is enabled.
Things I have tried so far (mostly based on recommendations from the #git #httpd IRC channels)
- Various combinations of the RewriteRule for ^gitweb$
- Added a RewriteBase
- Moved the Rewrite Rule for the trailing slash outside the directory stanza
The URL stubbornly remains 404 without a trailing slash.
FWIW, Version Info: Git 1.6.2.3 built from source, running on Debian 5
Ask Mefites - please help!
posted by your mildly obsessive average geek to technology (3 answers total)
Alias /gitweb /var/www/gitweband
<Directory "/var/www/gitweb">instead of what I've mentioned in the question.
Surprisingly, This does work - I can now type http://my.domain.com/gitweb and get the actual repo listing.
But I can't help but think that is not strictly correct - ie requesting "http://my.domain.com/foo" indicates one is looking for the file named "foo" whereas requesting "http://my.domain.com/foo/" is the correct way of requesting for the subdirectory "foo".
I would still like to know how to get the redirect to work if anyone can figure what's wrong with it.
posted by your mildly obsessive average geek at 1:28 AM on April 23, 2009