Page MenuHomePhabricator
Paste P3262

https://git.wikimedia.org -> https://phabricator.wikimedia.org/diffusion redirects
ActivePublic

Authored by Danny_B on Jun 16 2016, 11:30 PM.
<VirtualHost *:80>
ServerName git.wikimedia.org
# DocumentRoot ### TODO - add the path
##### https://git.wikimedia.org -> https://phabricator.wikimedia.org/diffusion redirects
##### @author [[meta:User:Danny B.]]
### Directives
# don't decode "%2F" in URL to "/"
AllowEncodedSlashes NoDecode
# allow URL rewriting
RewriteEngine On
### Static links
# home page
RewriteRule ^/$ https://phabricator.wikimedia.org/diffusion [L,R=301]
# searches & lists
RewriteRule ^/activity/?$ https://phabricator.wikimedia.org/diffusion/query/active/ [L,R=301]
RewriteRule ^/lucene/?$ https://phabricator.wikimedia.org/diffusion/query/advanced/ [L,R=301]
RewriteRule ^/(projects|repositories)/?$ https://phabricator.wikimedia.org/diffusion/query/all/ [L,R=301]
### Preformat
# ?r=<repo/name> -> /<repo/name>
RewriteCond %{QUERY_STRING} ^(.*&)?r=([0-9A-Za-z/_\.-]+).git(&.*)?$
RewriteRule ^/(blame|blob|commit|commitdiff|docs|history|log|patch|summary|tree)/$ /$1/%2.git [NE]
# remove "refs%2Fheads%2F" and "refs%2Fremotes%2Forigin%2F"
RewriteRule ^(.*)refs\%2[Ff](heads|remotes\%2[Ff]origin)\%2[Ff](.*)$ $1$3
# <repo%2Fname> -> <repo/name>
RewriteRule ^/(blame|blob|commit|commitdiff|docs|history|log|patch|summary|tree)/([0-9A-Za-z/_\.-]+)\%2[Ff](.*)\.git(.*)$ /$1/$2/$3.git$4 [N]
# <tag%2Fname> -> <tag%25252Fname>
RewriteRule ^/(blame|blob|commit|commitdiff|docs|history|log|patch|summary|tree)/([0-9A-Za-z/_\.-]+)\.git/([0-9A-Za-z_\.-]+)\%2[Ff]([^/]+)(.*)$ /$1/$2.git/$3\%25252F$4$5 [N]
# <path%2Fto%2Ffile> -> <path/to/file>
RewriteRule ^/(blame|blob|commit|commitdiff|docs|history|log|patch|summary|tree)/([0-9A-Za-z/_\.-]+)\.git/([^/]+)/([0-9A-Za-z/_\.-]+)\%2[Ff]([^/]*)$ /$1/$2.git/$3/$4/$5 [N]
### /commit/
### /commitdiff/
### /patch/
# https://git.wikimedia.org/<commit(diff)?|patch>/<repo%2Fname>.git/<commithash>
# -> https://git.wikimedia.org/<commit(diff)?|patch>/<repo/name>.git/<commithash>
# ---> https://phabricator.wikimedia.org/r/<(commit|patch)>/<repo/name>;<commithash>
RewriteRule ^/(commit|patch)(diff)?/([0-9A-Za-z/_\.-]+)\.git/([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])$ https://phabricator.wikimedia.org/r/$1/$3;$4 [NE,L,R=301]
### /blame/
### /blob/
### /docs/
### /history/
### /log/
### /summary/
### /tree/
# translate Gitblit actions to Diffusion actions
RewriteRule ^/(blame|blob|docs|tree)/(.*)$ /browse/$2 [NE]
RewriteRule ^/log/(.*)$ /history/$1 [NE]
RewriteRule ^/summary/(.*)$ /$1 [NE]
# https://git.wikimedia.org/<(blame|blob|history|log|tree)>/<repo%2Fname>.git/<commithash><(/<path%2Fto%2Ffile>)?>
# -> https://git.wikimedia.org/<(blame|blob|history|log|tree)>/<repo/name>.git/<commithash><(/<path/to/file>)?>
# ---> https://phabricator.wikimedia.org/r/p/<repo/name>;<(browse|history)>/master/<(<path/to/file>)?>;<commithash>
RewriteRule ^/(browse|history)/([0-9A-Za-z/_\.-]+)\.git/([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])(/([0-9A-Za-z/_\.-]+))?$ https://phabricator.wikimedia.org/r/p/$2;$1/master/$5;$3 [NE,L,R=301]
# https://git.wikimedia.org/<(blame|blob|history|log|summary|tree)>/<repo%2Fname>.git<(/<tag%2Fname><(/<path%2Fto%2Ffile>)?>)?>
# -> https://git.wikimedia.org/<(blame|blob|history|log|summary|tree)/<repo/name>.git<(/<tag%25252Fname><(/<path/to/file>)?>)?>
# ---> https://phabricator.wikimedia.org/r/p/<repo/name>;<(browse|history)?><(/<tag%25252Fname><(/<path/to/file>)?>)?>
RewriteRule ^/((browse|history)(/))?([0-9A-Za-z/_\.-]+)\.git((/[^/]+)(/([0-9A-Za-z/_\.-]+))?)?$ https://phabricator.wikimedia.org/r/p/$4;$2$6$3$8 [NE,L,R=301]
### Unmatched above
# redirect all remaining requests to the Diffusion main page
RewriteRule ^.*$ https://phabricator.wikimedia.org/diffusion [L,R=301]
</VirtualHost>