Hi. I want to set up a forwarding rule to redirect all URLs from /* to /near-me/*
I have very little knowledge on this so apologies if it’s a silly question. I’ve tried a few different ways and keep getting errors so would really appreciate any help.
Let’s say its https://domain-name.uk/. It has a few thousand location pages that all had the URL structure of /county-town/ and now the URL structure is /near-me/county-town/
The domain had pages with the structure /ABC-123/ however these same pages now have the structure of /near-me/ABC-123/. I’m trying to redirect all of the /ABC-123/ pages to /near-me/ABC-123/. (ABC and 123 are different for every page).
The ABC and 123 are still the same on the pages however /near-me/ has now been added before so I need a way of redirecting all pages to the new structure that has /near-me/ added.
Thanks very much for the help and sorry for the poor explanation!
Thanks very much for the help Sandro. I get the error message ‘Forwarding URL matches the target and would cause a redirect loop’ so can’t save the rule.
I just tried the second one actually so that will be why. For the first rule, which setting would you choose? Would it still be forwarding URL? If so, what would you enter for the destination URL?
As long as we can’t get the actual redirect up and running, the first rule is not relevant anyhow.
I am a bit puzzled right now, because I am getting the same error message as you do now and that very setup seemed to work before. I actually did expect that error originally anyhow, because it’s a known issue and was surprised when it actually went through.
Do you want to the new URL show up in the browser as well or is the request to the server enough?
Well, it can, if you can find a few to trick the check in the dashboard which I seemingly managed to do - somehow
At this point, I can’t reproduce the exact steps any more, I am afraid.
As I said, I actually expected that error message and was surprised it worked on the first try.
What should definitely work is using a Worker for that, but that will be paid if you exceed the requests on the free plan. If you can do it on the server, I’d go for that.
Tried a couple of approaches, but the check always shows up.
Even though I still doubt that, there is the chance that I redirected to example.com. I do doubt, that I set it up like that, because I do know better and because I think I remember it was the right URL, but I can’t rule it out any more. If I did, I’d slap myself.
Anyhow, even if I managed to play the system somehow, it’s obviously not straightforward to do so and in general I’d say Cloudflare does not support that yet - at least until someone checked out Page rule validation should check other page rules.
If you say you definitely want it to show up in the browser you can only implement it on the server or via a Worker. Preferably the former, though.