I want to set the path of cgit config (CGIT_CONFIG) in a directory with SetEnv.
But it seems that cgit can't find this env variable. My .htaccess is as follow:
Options +ExecCGI +Indexes +FollowSymLinks
#DirectoryIndex cgit.cgi I named cgit as index.cgi
SetEnv "CGIT_CONFIG" "/home/user_253/etc/cgitrc"
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.cgi/$1 [END,QSA]
RewriteCond %{QUERY_STRING} service=git-receive-pack
RewriteRule .* - [END,F]
Of course, I haven't access to main Apache config file...
Try using
SetEnvIf
(part of mod_setenvif) instead to set the environment variable.For example:
The
SetEnvIf
directive takes additional arguments, hence the need for two "simple" regex to effectively set the env var unconditionally.The "problem" with
SetEnv
(mod_env) is that it is processed very late. The request will have already been rewritten to/index.cgi
(by mod_rewrite) before theSetEnv
directive is processed. WhereasSetEnvIf
is processed before mod_rewrite handles the request. (Directives in Apache config files are not necessarily processed top to bottom. Different modules are processed independently.)Aside:
These two rules are possibly the wrong way round. Any URL that does not map to a file but includes the query string
service=git-receive-pack
will not be blocked.