Dynamic Redirect Urls

Hello,
I’m trying to do a 301 redirect with Cloudflare rules.
It would be like this:
Currently:
domain/category/id-nameproduct
domain/category/id-subid-nameproduct

for:
domain/nameproduct/id
domain/nameproduct/id-subid

Would it be possible with the redirect rule using $1 and $2?

Thanks

I think you would need $3 as well (for the second url):

id = $1
subid (or id-subid) = $2
nameproduct = $3

Rule 1:
domain/category/*-*
for
domain/$2/$1

Rule 2:
domain/category/*-*-*
for
domain/$3/$1-$2

2 Likes

Work with this rules:

Thanks

1 Like