summaryrefslogtreecommitdiff
path: root/etc/apache2/conf-available/local-cgit-legacy.conf
blob: 3a0f593a88245b0ba62a8e187bc7ae06975dd797 (plain)
  1. # Based on http://www.clearchain.com/blog/posts/cgit-upgrade-gitweb-retired
  2. #
  3. # Redirects mapping gitweb -> cgit
  4. #
  5. # Gitweb uses get targets seperated by ;
  6. #
  7. # /?...;...;...
  8. #
  9. # p = Project
  10. # a = Action like (
  11. # blob,
  12. # blob_plain,
  13. # commitdiff,
  14. # commit,
  15. # history,
  16. # log,
  17. # rss|atom,
  18. # shortlog,
  19. # summary,
  20. # tag,
  21. # tree,
  22. # snapshot
  23. # )
  24. # h = SHA Hash
  25. # hb= SHA Hash Tree Base
  26. # f= file/dir
  27. # sf= snapshot format
  28. #
  29. # Cgit uses the following:
  30. #
  31. # /project/action/?...
  32. #
  33. # action ( commit, log, diff, tree, tag, patch )
  34. #
  35. # id = SHA Hash
  36. # id2 = SHA Hash
  37. # h = head
  38. #
  39. # Translation rules
  40. #
  41. # Project is a straight redirect
  42. # ---
  43. # /?p=(.+)\.git; /$1/
  44. #
  45. # Action requires a mapping
  46. # ---
  47. # a=(blob|tree) /tree/
  48. # a=(blobdiff|commitdiff) /diff/
  49. # a=commit /commit/
  50. # a=(summary) /
  51. # a=(shortlog|log|history) /log/
  52. # a=tag /tag/
  53. # a=blob_plain /blob/
  54. # a=rss|atom /atom
  55. #
  56. # Targets require mapping
  57. # ---
  58. # h=(.+) id=$1
  59. # f=(.+) /$1
  60. # hb=(.+) id2=$1
  61. #
  62. # Now putting it all together
  63. #
  64. RewriteEngine On
  65. # blob
  66. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob;h=([^;]+);hb=([^;]+);f=([^;]+)
  67. RewriteRule ^/$ /%1.git/tree/%5?id=%3;id2=%4 [R=permanent,L,NE,QSD]
  68. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob;f=([^;]+);h=([^;]+);hb=([^;]+)
  69. RewriteRule ^/$ /%1.git/tree/%3?id=%4;id2=%5 [R=permanent,L,NE,QSD]
  70. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob;hb=([^;]+);f=([^;]+)
  71. RewriteRule ^/$ /%1.git/tree/%4?id=%3 [R=permanent,L,NE,QSD]
  72. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob;f=([^;]+)
  73. RewriteRule ^/$ /%1.git/tree/%3 [R=permanent,L,NE,QSD]
  74. # tree
  75. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tree;h=([^;]+);hb=([^;]+);f=([^;]+)
  76. RewriteRule ^/$ /%1.git/tree/%5?id=%4 [R=permanent,L,NE,QSD]
  77. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tree;hb=([^;]+);f=([^;]+)
  78. RewriteRule ^/$ /%1.git/tree/%4?id=%3 [R=permanent,L,NE,QSD]
  79. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tree;h=([^;]+);hb=([^;]+)
  80. RewriteRule ^/$ /%1.git/tree/?id=%4 [R=permanent,L,NE,QSD]
  81. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tree;hb=([^;]+)
  82. RewriteRule ^/$ /%1.git/tree/?id=%3 [R=permanent,L,NE,QSD]
  83. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tree
  84. RewriteRule ^/$ /%1.git/tree/? [R=permanent,L,NE,QSD]
  85. # commitdiff
  86. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blobdiff;h=([^;]+);hp=([^;]+);hb=([^;]+);f=([^;]+)
  87. RewriteRule ^/$ /%1.git/diff/%6?id2=%4;id=%3;id3=%5 [R=permanent,L,NE,QSD]
  88. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=commitdiff;h=([^;]+);hp=([^;]+)
  89. RewriteRule ^/$ /%1.git/diff/?id=%4;id2=%3 [R=permanent,L,NE,QSD]
  90. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=commitdiff;h=([^;]+)
  91. RewriteRule ^/$ /%1.git/diff/?id=%3 [R=permanent,L,NE,QSD]
  92. # commit
  93. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=commit;h=([^;]+)
  94. RewriteRule ^/$ /%1.git/commit/?id=%3 [R=permanent,L,NE,QSD]
  95. # shortlog
  96. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=shortlog;h=([^;]+)
  97. RewriteRule ^/$ /%1.git/log/?id=%3 [R=permanent,L,NE,QSD]
  98. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=shortlog
  99. RewriteRule ^/$ /%1.git/log/? [R=permanent,L,NE,QSD]
  100. # log
  101. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=log;h=([^;]+)
  102. RewriteRule ^/$ /%1.git/log/?id=%3 [R=permanent,L,NE,QSD]
  103. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=log
  104. RewriteRule ^/$ /%1.git/log [R=permanent,L,NE,QSD]
  105. # history
  106. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;h=([^;]+);hb=([^;]+);f=([^;]+)
  107. RewriteRule ^/$ /%1.git/log/%5?id=%4 [R=permanent,L,NE,QSD]
  108. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;f=([^;]+);h=([^;]+);hb=([^;]+)
  109. RewriteRule ^/$ /%1.git/log/%3?id=%4 [R=permanent,L,NE,QSD]
  110. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;f=([^;]+);h=([^;]+)
  111. RewriteRule ^/$ /%1.git/log/%3?id=%4 [R=permanent,L,NE,QSD]
  112. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;h=([^;]+);hb=([^;]+)
  113. RewriteRule ^/$ /%1.git/log/?id=%4 [R=permanent,L,NE,QSD]
  114. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;hb=([^;]+);f=([^;]+)
  115. RewriteRule ^/$ /%1.git/log/%4?id=%3 [R=permanent,L,NE,QSD]
  116. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=history;hb=([^;]+)
  117. RewriteRule ^/$ /%1.git/log/?id=%3 [R=permanent,L,NE,QSD]
  118. # tag
  119. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=tag;h=([^;]+)
  120. RewriteRule ^/$ /%1.git/tag/?id=%4 [R=permanent,L,NE,QSD]
  121. # blob_plain
  122. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob_plain;h=([^;]+);f=([^;]+)
  123. RewriteRule ^/$ /%1.git/blob/%4?id=%3 [R=permanent,L,NE,QSD]
  124. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob_plain;f=([^;]+);hb=([^;]+)
  125. RewriteRule ^/$ /%1.git/plain/%3?id2=%4 [R=permanent,L,NE,QSD]
  126. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=blob_plain;f=([^;]+)
  127. RewriteRule ^/$ /%1.git/plain/%3 [R=permanent,L,NE,QSD]
  128. # rss|atom
  129. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=(rss|atom);h=refsheads/([^;]+)
  130. RewriteRule ^/$ /%1.git/atom?h=%4 [R=permanent,L,NE,QSD]
  131. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=(rss|atom)
  132. RewriteRule ^/$ /%1.git/atom [R=permanent,L,NE,QSD]
  133. # snapshot
  134. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?;a=snapshot;h=([^;]+);sf=([^;]+)
  135. RewriteRule ^/$ /%1.git/snapshot/%3.tar.gz [R=permanent,L,NE,QSD]
  136. # summary
  137. RewriteCond %{QUERY_STRING} p=([^;]+)(\.git)(;a=summary)?$
  138. RewriteRule ^/$ /%1 [R=permanent,L,NE,QSD]
  139. # Failsafes in case nothing above matches,
  140. # try at least to put the person in the project, else root of cgit
  141. RewriteCond %{QUERY_STRING} p=([^;]+?)(\.git)?.*
  142. RewriteRule ^/$ /%1 [R=temp,L,NE,QSD]
  143. RewriteCond %{QUERY_STRING} .+
  144. RewriteRule ^/.+ / [R=temp,L,NE,QSD]