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.
Here’s the solution
Thanks for the reply. I have seen that article and unfortunately I’m still unsure on how I can make it work.
I need to set up a forwarding URL rule from /* to /near-me/* with a few exceptions such as /blog/ and /privacy/ etc. Thanks in advance.
can you send the url which needs to be forwarded ? remove it for sending if you want to maintain privacy .
Waiting for you reply .
I’d prefer to keep it private if possible.
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/
Actually thats a bit confusing .
Can you explain it by example.com to sub.example.com like that for better understanding
It’s the same domain but I’ll try to elaborate.
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!
You will need two pages rules, in that order
/near-me/* with some dummy rule to stop requests for that path
*domain-name.uk/* redirecting to
That should be it.
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 would have actually expected that, but it just worked beautifully when I just tried it.
In which order did you set it up and where did you get the error?
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?
For the first you you just need mentioned dummy settings. Best to use the cache level.
Interestingly, right now I can’t set it up either any more. Probably depends on the order of steps. Giving it a quick look.
Thanks very much for the help Sandro.
I basically just need inner pages redirecting to /near-me/* and homepage, blog, privacy etc remaining the same.
I’m a bit confused by what you mean by dummy settings. Apologies - as I mentioned I have very limited knowledge!!
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?
Yes I need the URL in the browser as the site has thousands of 404s at the moment due to changing the URL structure.
Any chance of configuring this on your server?
I will try server now. Can this not be done on Cloudflare?
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.
Thanks very much for your help Sandro I really appreciate it I’ll try 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.