I have a little problem.
I want to be able to use a location such as git.my-domain.org/repo-a to set an environment that is used in git.my-domain.org/ as /repo-a is changed to / using a rewrite rule (which I must use?)
<VirtualHost *:80>
ServerName git.my-domain.org
DocumentRoot /usr/share/gitweb
RewriteEngine On
<Location /repo-a>
RewriteRule /repo-a(.*) /$1 [PT]
SetEnv GITWEB_CONFIG "/var/lib/gitolite/repositories/repo-a.git/gitweb/gitweb_config.perl"
</Location>
<Directory />
AllowOverride All
Options +FollowSymLinks +ExecCGI
Order allow,deny
Allow from all
DirectoryIndex gitweb.cgi
AddHandler cgi-script .cgi
</Directory>
</VirtualHost>
I need to use a rewrite rule because /usr/share/gitweb/repo-a does not exist (or do I?), and I don't have any intention of creating any directories there. What I want is to use SetEnv GITWEB_CONFIG from /daily-backups and use it under /. But it seems that it isn't set, I've also tried using SetEnvIf with no success.
SetEnvIf Request_URI ".*repo-a" GITWEB_CONFIG "/var/lib/gitolite/repositories/repo-a.git/gitweb/gitweb_config.perl"
There is probably an automated way to use a RewriteRule together with SetEnv so that I don't have to create a new for another repository? For example:
SetEnvIf Request_URI ".*repo-a" GITWEB_CONFIG "/var/.../$1.git/gitweb/gitweb_config.perl"
I know I can symlink directories and using /var/lib/.../repo-a.git/gitweb/ as a DocumentRoot instead, but I'd rather avoid this as it would increase the number of .conf files (or be very cluttered).
Question summary
- Do I need a rewrite rule because the directory doesn't exist?
- How do I pass an environment variable to another "location"?
- Is there a way to simplify SetEnvIf or SetEnv to make use of the URI?