2 ServerName git.openezx.org
4 ErrorLog /var/log/apache2/git.openezx.org/error.log
5 CustomLog /var/log/apache2/git.openezx.org/access.log common
8 # Redirects mapping gitweb -> cgit
9 # Inspired from: http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired
11 # Gitweb uses get targets seperated by ;
31 # hb= SHA Hash Tree Base
35 # Cgit uses the following:
37 # /project/action/?...
39 # action ( commit, log, diff, tree, tag, patch )
47 # Project is a straight redirect
49 # /?p=(.+)\.git; http://cgit.openezx.org/$1/
51 # Action requires a mapping
53 # a=(blob|tree) /tree/
54 # a=(blobdiff|commitdiff) /diff/
57 # a=(shortlog|log|history) /log/
62 # Targets require mapping
68 # Now putting it all together
71 #RewriteLog /tmp/rewrite.log
75 RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+)/(.+):/(.+) [OR]
76 RewriteCond %{query_string} p=(.+)(\.git);a=blob;h=(.+);hb=(.+);f=(.+)
77 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%5?id=%3;id2=%4 [R,L,NE]
79 RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+):/(.+) [OR]
80 RewriteCond %{query_string} p=(.+)(\.git);a=blob;hb=(.+);f=(.+)
81 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%4?id=%3 [R,L,NE]
83 RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+);hb=(.+)
84 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%3?id=%4;id2=%5 [R,L,NE]
86 RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+)
87 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%3?id=%4 [R,L,NE]
90 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+):/(.+) [OR]
91 RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+);f=(.+)
92 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%5?id=%4 [R,L,NE]
94 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+):/(.+) [OR]
95 RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+);f=(.+)
96 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/%4?id=%3 [R,L,NE]
98 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+) [OR]
99 RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+)
100 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/?id=%4 [R,L,NE]
102 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+) [OR]
103 RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+)
104 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/?id=%3 [R,L,NE]
106 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree [OR]
107 RewriteCond %{query_string} p=(.+)(\.git);a=tree
108 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tree/? [R,L,NE]
111 RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+):/(.+) [OR]
112 RewriteCond %{query_string} p=(.+)(\.git);a=blobdiff;h=(.+);hp=(.+);hb=(.+);f=(.+)
113 RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/%6?id2=%4;id=%3;id3=%5 [R,L,NE]
115 RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+) [OR]
116 RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+);hp=(.+)
117 RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/?id=%4;id2=%3 [R,L,NE]
119 RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+) [OR]
120 RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+)
121 RewriteRule ^/.*$ http://cgit.openezx.org/%1/diff/?id=%3 [R,L,NE]
124 RewriteCond %{REQUEST_URI} /(.+)(\.git)/commit/(.+) [OR]
125 RewriteCond %{query_string} p=(.+)(\.git);a=commit;h=(.+)
126 RewriteRule ^/.*$ http://cgit.openezx.org/%1/commit/?id=%3 [R,L,NE]
129 RewriteCond %{REQUEST_URI} /(.+)(\.git)/summary [OR]
130 RewriteCond %{query_string} p=(.+)(\.git);a=summary
131 RewriteRule ^/.*$ http://cgit.openezx.org/%1/? [R,L,NE]
134 RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog/(.+) [OR]
135 RewriteCond %{query_string} p=(.+)(\.git);a=shortlog;h=(.+)
136 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE]
138 RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog [OR]
139 RewriteCond %{query_string} p=(.+)(\.git);a=shortlog
140 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/? [R,L,NE]
143 RewriteCond %{REQUEST_URI} /(.+)(\.git)/log/(.+) [OR]
144 RewriteCond %{query_string} p=(.+)(\.git);a=log;h=(.+)
145 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE]
147 RewriteCond %{REQUEST_URI} /(.+)(\.git)/log [OR]
148 RewriteCond %{query_string} p=(.+)(\.git);a=log
149 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log? [R,L,NE]
152 RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+):/(.+) [OR]
153 RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+);f=(.+)
154 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%5?id=%4 [R,L,NE]
156 RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+);hb=(.+)
157 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%3?id=%4;id2=%5 [R,L,NE]
159 RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+)
160 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%4?id=%3 [R,L,NE]
162 RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+)
163 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%3?id=%4 [R,L,NE]
165 RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+) [OR]
166 RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+)
167 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%4 [R,L,NE]
169 RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) [OR]
170 RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+);f=(.+)
171 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%4?id=%3 [R,L,NE]
173 RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+) [OR]
174 RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+)
175 RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/?id=%3 [R,L,NE]
178 RewriteCond %{REQUEST_URI} /(.+)(\.git)/tag/(.+) [OR]
179 RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=(.+)
180 RewriteRule ^/.*$ http://cgit.openezx.org/%1/tag/?id=%3 [R,L,NE]
183 RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+):/(.+) [OR]
184 RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;h=(.+);f=(.+)
185 RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%4?id=%3 [R,L,NE]
187 RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+);hb=(.+)
188 RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%3?id2=%4 [R,L,NE]
190 RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+) [OR]
191 RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+)
192 RewriteRule ^/.*$ http://cgit.openezx.org/%1/plain/%3 [R,L,NE]
195 RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom)/refs/heads/(.+) [OR]
196 RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom);h=refsheads/(.+)
197 RewriteRule ^/.*$ http://cgit.openezx.org/%1/atom?h=%4 [R,L,NE]
199 RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom) [OR]
200 RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom)
201 RewriteRule ^/.*$ http://cgit.openezx.org/%1/atom? [R,L,NE]
204 RewriteCond %{REQUEST_URI} /(.+)(\.git)/snapshot/(.+)(\.tar\.gz|\.tar\.bz2) [OR]
205 RewriteCond %{query_string} p=(.+)(\.git);a=snapshot;h=(.+);sf=(.+)
206 RewriteRule ^/.*$ http://cgit.openezx.org/%1/snapshot/%3.tar.gz [R,L,NE]
208 # Fail safes incase nothing above matches, try at least to put the person in the project
209 RewriteCond %{REQUEST_URI} /(.+)\.git.* [OR]
210 RewriteCond %{query_string} p=(.+)\.git.*
211 RewriteRule ^/.*$ http://cgit.openezx.org/%1/? [R,L,NE]
213 # Or else in the root of cgit
214 RewriteRule ^.* http://cgit.openezx.org/ [R,L,NE]