Score:0

nginx: Redirection from old to new git base URL

cm flag

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!

Score:0
us flag

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;
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.