Skip to content

Instantly share code, notes, and snippets.

@aelindeman
Created November 18, 2015 16:26
Show Gist options
  • Save aelindeman/539195b5ed82c03cddd5 to your computer and use it in GitHub Desktop.
Save aelindeman/539195b5ed82c03cddd5 to your computer and use it in GitHub Desktop.
Apache 2.4 configuration for cgit
DocumentRoot /usr/share/cgit
<Directory "/usr/share/cgit">
Require all denied
<FilesMatch "\.(css|gif|html?|ico|jpe?g|js|png|txt)$">
Require all granted
</FilesMatch>
</Directory>
ScriptAlias /cgi-bin /usr/lib/cgit
<Directory "/usr/lib/cgit">
Require all denied
<Files "cgit.cgi">
Require all granted
</Files>
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine on
# redirect to https
<IfModule mod_ssl.c>
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# can't use REQUEST_FILENAME because of passthrough, but this works too
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^/?(.*)$ /cgi-bin/cgit.cgi/$1 [PT]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment