Hello,
We apologize for the issue you are facing with the regex function in Rank Math. Based on your requirements, you want to match a URL and remove the last part that includes a hyphen followed by a variable number of characters before .html
.
To achieve this, you can use the following regex pattern:
Regex Source URL:
/shop/(.*?)-[a-zA-Z0-9]+.html
Destination URL:
/produkt/$1
Explanation:
/shop/
: This part matches the beginning of your URL.
- *`(.?)
**: This captures everything after
/shop/up to the last hyphen. The
?` makes it non-greedy, so it stops at the first occurrence of the hyphen.
-[a-zA-Z0-9]+
: This matches the hyphen followed by one or more alphanumeric characters (which can vary).
.html
: This matches the .html
at the end of the URL.
Example:
For your example URL https://rankmath.com/kb/solving-redirection-issues-using-rank-math-seo/ this regex will capture
hjulsaet-til-backappand redirect it to
/produkt/hjulsaet-til-backapp`.
Make sure to select Regex as the matching type when setting this up in Rank Math. If you continue to experience issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.
Thank you for raising this concern!
Sources:
How to Use Regex Redirects in Rank Math » Rank Math
How to Remove a Specific Word From Your Permalinks (URLs) » Rank Math
Yeah, sorry, that didnt work, i used it, and cleansed the cache, stil doestn work.
Hello,
You can try to add the following regex redirection on your website and see if that works for you:
Source: shop/(.*)-([0-9]+)([a-zA-Z]+).html
Redirection Type: regex
Destination URL: /produkt/$1
Let us know how it goes. Looking forward to helping you.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.