0

I would like to redirect the old base url of git repositories. I use the following code:

location ~ ^/scm/git/(.*) {
    return 301 /scm/repo/git/$1;
}

In the browser, the redirection works fine, but when I try to clone the repository, I get the following error message:

fatal: unable to update url base from redirection:
asked for: https://example.com/scm/git/xxxx/info/refs?service=git-upload-pack
redirect: https://example.com/scm/repo/git/xxxx/info/refs

Can you please help me, what have I forgotten? Thank you very much!

Christian
  • 3
  • 1

1 Answers1

0

In location, nginx uses only normalised URI, which doesn't include query arguments.

You need to use the following to include query arguments:

location ~ ^/scm/git/(.*) {
    return 301 /scm/repo/git/$1$is_args$args;
}
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63