Redirecting from /#invite_token= to /admin/#invite_token=

hi folks,

I’m putting the netlify-cms admin under /admin. This works fine except when using netlify Identity, it sends admin users to the root to verify/setup their admin account, rather than /admin, and I can’t modify that Identity template unless I move up a plan. I also use Large Media, so I can’t put the admin functionality under a different sub-domain and link to the same repo. Long and short: /admin is where it lives.

This works except for setup, when netlify Identity send setup links such as /#invite_token=some_token. I would like to use redirects to change that, such as:

/#invite_token=:invite_token /admin/#invite_token=:invite_token 301!

or

[[redirects]]
  from = "/#invite_token=:invite_token"
  to = "/admin/#invite_token=:invite_token"
  status = 301
  force = true

however, this doesn’t seem to work; after some local and remote testing, I’m starting to strongly suspect that the underlying proxy/redirect engine can’t handle #. Escaping # doesn’t seem to work either.

I can add JS into the landing page to do this redirect based upon the anchor tag, but I would prefer to do it at the redirect level. Suggestions?

if it helps others, here is the bit of javascript I used to redirect from the index file to the admin…

      if (location.href.indexOf("#invite_token") != -1) {
        var urlSplit = document.URL.split("#");
        window.location = `/admin/#${urlSplit[1]}`;
      }
1 Like

Hey @agreene

Correct, using a hash character in a redirect is not possible. It is nothing to do with the underlying engine. The reason is outlined in this post

oh jez, I totally didn’t find that post. I was searching for anchor.

bummer, but understandable! Thanks for taking the time to highlight this past post.