check you remote

git remote -v

probably yours remote is https://server/../project and does not end with .git ( https://server/../project.git)

Answer from Dmitry on Stack Overflow
🌐
Reddit
reddit.com › r/gitlab › "you are being redirected away from gitlab" pages don't redirect
r/gitlab on Reddit: "You are being redirected away from GitLab" pages don't redirect
May 22, 2024 -

We have a few links to CI artifacts in our READMEs and project badges, so that it's easy to get to generated documentation and reports. These links are in this sort of format:

https://gitlab.com/mygroup/myproject/-/jobs/artifacts/main/file/dir1/dir2/dir3/index.html?job=build

When following one of these links, GitLab serves a page that says "You are being redirected away from GitLab" and then it has a link to the actual artifact hosted on GitLab pages, like:

https://mygroup.gitlab.io/-/myproject/-/jobs/1234567890/artifacts/dir1/dir2/dir3/index.html

I seem to remember that these "redirect" pages used to actually redirect to the latter address after a second or two, but it seems that they now require that you click on the link.

Am I misremembering the old behavior? Is there some way to get that behavior? Does anyone else find it kind of annoying having to always click on that second link?

Gitlab pages routing me to 404. May 27, 2025
r/gitlab
last yr.
Self hosted gitlab redirecting Jul 29, 2022
r/gitlab
4y ago
Gitlab pages stuck in Private? Sep 29, 2024
r/gitlab
last yr.
Is Gitlab down or is it just me? Jul 17, 2020
r/gitlab
6y ago
More results from reddit.com
🌐
GitLab
gitlab.com › gitlab.org › #439861
browsing text-artifacts redirects "away from gitlab" (#439861) · Issues · GitLab.org / GitLab · GitLab
January 31, 2024 - consider a job that creates some files (binary ones as well as text-based ones) and makes them available via artifacts:
Discussions

Why is there a redirect when I try to access my Gitlab Pages site?
I used to have my personal blog on Github. However, I would like to always keep the source code of my blog private. My subscription as student will end there this year and I think I will not be able to renew it. So, I thought about publishing my blog here, with Gitlab, where you have unlimited ... More on forum.gitlab.com
🌐 forum.gitlab.com
2
1
February 14, 2022
GitLab open HTML from artifact in new tab instead of downloading it - Stack Overflow
Based on this post I tested gitlab.com/GROUP/PROJECT/-/jobs/artifacts/master/file/pylint/… and it seems to point me to the artifacts of the latest job but with an annoying redirection stating "You are being redirected away from GitLab This page is hosted on GitLab pages but contains ... More on stackoverflow.com
🌐 stackoverflow.com
Cloudflare (e.g. Gitlab login page) 503 / infinite redirect issue
Version info: 2.5.0-1 Does the bug happen if you start with --temp-basedir? Yes. Description Gitlab login page returns 503 and infinitely redirects: Not sure if it's more of a browser or a Gitl... More on github.com
🌐 github.com
82
May 28, 2022
Gitlab redirecting loop - Stack Overflow
yesterday I installed gitlab on a vm of mine and configured everything to work with it. Gitlab listens on port 8081 of my domain (e.g. domain:8081). I have an apache instance which listens to port ... More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 8
51

check you remote

git remote -v

probably yours remote is https://server/../project and does not end with .git ( https://server/../project.git)

2 of 8
26

What the warning means

As the other answers have explained, there's a slight difference between the URL that you have saved and the one that the server uses. "Slight" means that it is there, but it can be fixed automatically, so Git doesn't give an error, but rather a warning.

How to get rid of the warning: manually...

To get rid of it you can update the URL that you are using, ensuring it matches the correct one. If you want to do it manually, you have to use the command

git remote set-url <remote_name> <correct_remote_path>

where the remote_name is usually origin, and comes from git remote, and correct_remote_path is the one shown by the warning.

...And with a Bash script. Variant 1, safe but partly manual

I've written a small Bash script to check automatically for that warning. It will tell whether there's nothing to do, or it will print the command to use to remove the warning. It won't run it automatically, just to be safe.

I've chosen to use a function, which you can copy and paste directly in your shell, so you don't have to worry about saving it to a file, checking the file's path, and then deleting it. Here it is:

function check_git_redirection_warning {
    remote_name="$(git remote)";
    wrong_remote_path="$(git remote get-url $remote_name)";
    correct_remote_path="$(git fetch --dry-run 2> >(awk '/warning: redirecting to/ { print $4}'))";
    if [ -z "${correct_remote_path-}" ]; then
        printf "The path of the remote '%s' is already correct\n" $remote_name;
    else
        printf "Command to change the path of remote '%s'\nfrom '%s'\n  to '%s'\n" $remote_name $wrong_remote_path $correct_remote_path;
        printf "git remote set-url %s %s\n" $remote_name $correct_remote_path;
    fi
}

How to run it

After you have copied the script and pasted it in your shell (required only once), just go to your Git directory where you are seeing the problem and enter check_git_redirection_warning. Check the generated command and, if it makes sense (it should, but let's be safe!), just copy and paste it into the shell.

How it works

  • First, it runs git remote to get the name of the default remote (usually origin)
  • Then it finds the URL that is currently configured, and that is (or could be) wrong, by running git remote get-url $remote_name.
  • Then it gets the correct URL. I haven't found a direct way to find it, so this is what I do: I run git fetch with the --dry-run option (a dryrun does nothing, so nothing gets actually fetched. This helps in case you don't want to change anything, although there's normally no reason to avoid running fetch). If there's the warning, Git prints it to STDERR. To capture it I use process substitution, and then I parse the message with AWK (which is normally available on any system) and get the 4th word. I think this part would fail if there were spaces in the URL, but there shouldn't be any, so I haven't bothered to make it more robust.
  • At this point it checks whether the warning has been found (together with the correct URL): if not, there's nothing to do, so it just prints a message and exits.
  • If the correct URL has been found, it prints a message showing both the old and the new one, and then it prints the command that must be run to apply the change.

Variant 2, unsafe but fully automatic

If you trust my script and want to also run the command, instead of just printing it, you can use this variant:

function remove_git_redirection_warning {
    remote_name="$(git remote)"
    wrong_remote_path="$(git remote get-url $remote_name)"
    correct_remote_path="$(git fetch --dry-run 2> >(awk '/warning: redirecting to/ { print $4}'))"
    if [ -z "${correct_remote_path-}" ]; then
        printf "The path of the remote '%s' is already correct\n" $remote_name;
    else
        mycmd=(git remote set-url "$remote_name" "$correct_remote_path")
        printf '%s ' "${mycmd[@]}"; printf "\n";
        "${mycmd[@]}"
    fi
}

How it works

It's very similar to the first one, but instead of printing the command, it saves all the parts into an array called mycmd and then runs it with "${mycmd[@]}".

How to run the script in all the Git repositories

So far we've seen how to fix the warning in one repo. What if you have many, and want to update them all? You can use this other script here:

git_directories="$(find . -name ".git" -exec dirname {} \;)"

for git_dir in $git_directories; do
    printf "Entering directory %s\n" $git_dir
    cd $git_dir
    remove_git_redirection_warning
    printf "\n"
    cd -
done

It finds all the repositories by looking for directories containing .git (both as a file and as a directory: it's normally a directory, but it's a file for submodules). Then, for each repo it goes inside it, calls the function, and goes back.

🌐
GitLab
forum.gitlab.com › general
Why is there a redirect when I try to access my Gitlab Pages site? - General - GitLab Forum
February 14, 2022 - I used to have my personal blog on Github. However, I would like to always keep the source code of my blog private. My subscription as student will end there this year and I think I will not be able to renew it. So, I thought about publishing my blog here, with Gitlab, where you have unlimited ...
🌐
Stack Overflow
stackoverflow.com › questions › 75792039 › gitlab-open-html-from-artifact-in-new-tab-instead-of-downloading-it
GitLab open HTML from artifact in new tab instead of downloading it - Stack Overflow
Based on this post I tested ... "You are being redirected away from GitLab This page is hosted on GitLab pages but contains user-generated content and may contain malicious code....
🌐
GitLab
docs.gitlab.com › gitlab docs › contribute › contribute to documentation › redirects
Redirects in GitLab documentation | GitLab Docs
In some cases you can skip adding the redirect and just delete the file. The page must have already been removed from (or never existed in) the navigation, and one of the following must be true:
🌐
GitLab
gitlab.com › gitlab.org › merge requests › !68664
Fix artifacts entry incorrectly redirecting to GitLab Pages (!68664) · Merge requests · GitLab.org / GitLab · GitLab
August 20, 2021 - When GitLab Pages and the Pages artifacts server are enabled, retrieving a HTML or text file would cause Projects#ArtifactsController#file to redirect to a GitLab Pages link. However,...
Find elsewhere
🌐
GitHub
github.com › qutebrowser › qutebrowser › issues › 7208
Cloudflare (e.g. Gitlab login page) 503 / infinite redirect issue · Issue #7208 · qutebrowser/qutebrowser
May 28, 2022 - Does the bug happen if you start with --temp-basedir? Yes. Description Gitlab login page returns 503 and infinitely redirects: Not sure if it's more of a browser or a Gitlab issue. But it works with Firefox. How to reproduce :open https://gitlab.com/users/sign_in/ As to what triggers this response in the first place, Gitlab might react to an IP address from China (tried from 2 locations), and to known proxy subnets (tried Fremont, US).
Author: qutebrowser
🌐
GitLab
codebase.helmholtz.cloud › fwcc › hzdr-gitlab › work items › #107
GitLab Pages broken with infinite redirect loop (#107) · Issues · FWCC / HZDR-GitLab · GitLab
January 5, 2021 - If you connect from outside the DFN network, you may briefly see a proof-of-work challenge that completes automatically within seconds. DFN IP addresses are excluded and unaffected. Please get in touch via support@hifis.net if we are missing certain ranges. Currently, GitLab pages is broken and not accessible. There is an infinite redirect loop as shown with below curl command:
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › deploy and release your application › gitlab pages › redirects
GitLab Pages redirects | GitLab Docs
March 15, 2022 - GitLab does not support Netlify force option to change this behavior. A default status code of 301 is applied if no status code is provided, but you can explicitly set your own. The following HTTP codes are supported: ... 200: Standard response for successful HTTP requests. Pages serves the content in the to rule if it exists, without changing the URL in the address bar. To create a redirect, add a rule that includes a from path, a to path, and an HTTP status code:
🌐
Stack Overflow
stackoverflow.com › questions › 79213637 › disable-gitlab-oauth-redirecting-page
http redirect - Disable Gitlab OAuth redirecting page - Stack Overflow
I am using the OAuth sign in through gitlab for my webapp and although it seems to be fully functional without any errors, there is a split second during the sign in process where you can see a plain white page with a large text "Redirecting" and a link below it.
🌐
GitLab
forum.gitlab.com › how to use gitlab
Why gitlab page keep redirect to gitlab login? - How to Use GitLab - GitLab Forum
September 27, 2019 - I hosted a static site on Gitlab.com and just while ago it still worked fine until now. If I login to Gitlab, I can access to my site. But if I log out and go to my site it will redirect to login page. What’s happening? …
🌐
GitHub
github.com › jgraph › drawio › issues › 1992
Invalid redirect URL error when authenticating to private gitlab · Issue #1992 · jgraph/drawio
May 8, 2021 - Changing the redirect URL in GitLab to '.../gitlab' instead of '.../gitlab.html' fixes the error on the GitLab side, but authentication still fails because Diagrams doesn't respond to the '.../gitlab' URL, it wants the '.html' extension. Downgrading to v14.6.2 fixes this, so there was a regression in constructing the redirect_uri since then. ... No fields configured for issues without a type. ... You can’t perform that action at this time.
Author: jgraph
🌐
GitLab
gitlab.com › gitlab.org › #30013
Redirect GitLab API calls when necessary, after a project transfer or rename (#30013) · Issues · GitLab.org / GitLab · GitLab
July 10, 2019 - Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
🌐
GitLab
gitlab.com › gitlab.org › #247674
Login redirects for SSO flow do not redirect the user back to the originally intended page (#247674) · Issues · GitLab.org / GitLab · GitLab
September 10, 2020 - ### Summary When using SSO (login times out every workday for me), attempting to access a Gitlab URL while logged out redirects to login flow which does not subsequently redirect back to the originally intended URL. This causes a bit of time wastage every day due to having to find the original link again e.g. on our issue tracker and clicking it again. ### Steps to reproduce * Uses is logged out * User clicks on some off-Gitlab link to Gitlab resource e.g. merge request ### What is the current *bug* behavior?
🌐
GitLab
gitlab.com › gitlab.org › #426435
"Use unique domain" causes a redirect back to gitlab.io subdomain when using a custom domain (#426435) · Issues · GitLab.org / GitLab · GitLab
September 27, 2023 - Summary I tried to set up GitLab Pages for the first time and was very confused when my custom domain kept...