Help setting up a redirect rule

Hi, I am trying to set up a rule that redirect duplicate links to the original link. Basically, I would need to redirect instances of: [or "-2", "-3" etc.]


The part should always be the same, while the part between brackets has to be replaced. I’m trying to do that in the “Redirect rules” page with a custom expression:

URI Full - matches regex -[\w-]*{1}\-[0-9]$


Dynamic -[\w-]*{1}$ - 301/302

Would this work correctly?



Is it right to say you want to remove the -n ending from the URL? If that’s the case, could n be greater than 9? Do you ever have URLs ending in -10 or greater?

Hi and thank you.
No, it would be impossible. “n” would always be between 1 and 9.

Ok, so first the basic test is availability. Are you on a Business or Enterprise plan? Only those levels have regex available.

Second challenge is to make sure your filter expression is right. Have you tested this regex somehow? I’m not a regex expert, but I believe you could make is simpler by matching against query string only:

URI Query matches "id=.*-[0-9]$"

Please test this filter to see if it’s working, and doesn’t mess with any other request patterns you may have.

We have a Business plan.
The regex indeed works, sir.
But since for now we need it only for one specific path, using only the query string would involve other pages as well. So I guess the first piece would necessarily be:

URI - “/people?id=.*-[0-9]$”

The next step is what I’m more worried about, as I’m not sure I completely understand the regex_replace() function and the capture groups.



1 Like


I believe this should work.

concat("", regex_replace( http.request.uri.query, "id=(.*)-[0-9]$", "id=${1}" ) )