Hash URL Redirect

Want to redirect Domain.Old/#x to Domain.New/#x
I know it’s possible in the New direction (Does CloudFlare Support Hashes in 301 Forwarded URLs)
but is there any way to retain the x hash info coming in from the Old?

My guesses:

Today urgent, so would really value anyone who can respond rapidly!

Retain it and do what with it? Your destination URL doesn’t use it. It uses “y” instead.

2 Likes

ha! tried to get too clever with algebra! Edited!
Any ideas on whether I can pass x through?

Oh! Now I get it! Those are Anchors, right?

There is a Redirect Worker, but as written, it does not appear to forward the anchor.

https://developers.cloudflare.com/workers/examples/redirect

const url = new URL(request.url)  
const { pathname, search } = url

which line implies that @sdayman ?
Unfamiliar with Workers in general, and haven’t come across the url method (looks like Javascript to me but not sure whether this is some specific package)

But they do. I just tested it. Keep in mind that you will need to set them up like this:

domain.old/* ==(302)==> https://www.domain.new/$1
(You can take a 301 later, when you verified it works as you expect it to.)

If you now call:

https://domain.old/#12345
you will be redirected (302) to:
https://www.domain.new/#12345

If you dont like the www, just remove it from the targetURL

You can do it with workers, but why complicated if it’s possible to be done more easy?

If something does not work, just post the real domains and your actual PageRules. (screenshot)

1 Like

That’s a redirect for everything. I was thinking only a match if there was an anchor. I was focused on the wrong requirement.

1 Like

You’re a hero: panic about nothing!
The Website Builder told me it wasn’t possible: L. Warner (aka Cerulean) Writes - Carrd reinvents the WebPage with hash-sections: #winner or made a hash of it? (#tech) (note how I used an anchor in a traditional way for once :D)
Maybe he only meant in traditional DNS.
Due to magic of Cloudflare Proxy, and Page Rules as you’ve said: A-side anchor of
Smalltown Dreamer - by Cerulean / 'MC Beastly' (2021) is correctly redirecting (actually with a 301) to A-side anchor of Smalltown Dreamer - by Cerulean / 'MC Beastly' (2021)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.