Initial import
[gitweb_cgit_migration.git] / git.openezx.org
1 <VirtualHost *:80>
2         ServerName      git.openezx.org
3
4         ErrorLog        /var/log/apache2/git.openezx.org/error.log
5         CustomLog       /var/log/apache2/git.openezx.org/access.log common
6
7         #
8         # Redirects mapping gitweb -> cgit
9         # Inspired from: http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired
10         #
11         # Gitweb uses get targets seperated by ;
12         #
13         # /?...;...;...
14         #
15         # p = Project
16         # a = Action like (
17         #       blob,
18         #       blob_plain,
19         #       commitdiff,
20         #       commit,
21         #       history,
22         #       log,
23         #       rss|atom,
24         #       shortlog,
25         #       summary,
26         #       tag,
27         #       tree,
28         #       snapshot
29         #     )
30         # h = SHA Hash
31         # hb= SHA Hash Tree Base
32         # f= file/dir
33         # sf= snapshot format
34         #
35         # Cgit uses the following:
36         #
37         # /project/action/?...
38         #
39         # action ( commit, log, diff, tree, tag, patch )
40         #
41         # id = SHA Hash
42         # id2 = SHA Hash
43         # h = head
44         #
45         # Translation rules
46         #
47         # Project is a straight redirect
48         # ---
49         # /?p=(.+)\.git;       http://cgit.openezx.org/$1/
50         #
51         # Action requires a mapping
52         # ---
53         # a=(blob|tree)                 /tree/
54         # a=(blobdiff|commitdiff)       /diff/
55         # a=commit                      /commit/
56         # a=(summary)                   /
57         # a=(shortlog|log|history)      /log/
58         # a=tag                         /tag/
59         # a=blob_plain                  /blob/
60         # a=rss|atom                    /atom
61         #
62         # Targets require mapping
63         # ---
64         # h=(.+)     id=$1
65         # f=(.+)     /$1
66         # hb=(.+)    id2=$1
67         #
68         # Now putting it all together
69         #
70         RewriteEngine On
71         #RewriteLog /tmp/rewrite.log
72         #RewriteLogLevel 5
73
74         # blob
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]
78
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]
82
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]
85
86         RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+)
87         RewriteRule ^/.*$  http://cgit.openezx.org/%1/tree/%3?id=%4 [R,L,NE]
88
89         # tree
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]
93
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]
97
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]
101
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]
105
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]
109
110         # commitdiff
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]
114
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]
118
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]
122
123         # commit
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]
127
128         # summary
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]
132
133         # shortlog 
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]
137
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]
141
142         # log
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]
146
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]
150
151         # history
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]
155
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]
158
159         RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+)
160         RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%4?id=%3 [R,L,NE]
161
162         RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+)
163         RewriteRule ^/.*$ http://cgit.openezx.org/%1/log/%3?id=%4 [R,L,NE]
164
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]
168
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]
172
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]
176
177         # tag
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]
181
182         # blob_plain
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]
186
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]
189
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]
193
194         # rss|atom
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]
198
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]
202
203         # snapshot
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]
207
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]
212
213         # Or else in the root of cgit
214         RewriteRule ^.* http://cgit.openezx.org/ [R,L,NE]
215 </VirtualHost>