Fix my .htaccess rewrite REGEX code (simple)

BR0C0LLI

Newbie
Joined
Nov 18, 2022
Messages
10
Reaction score
1
After web migration and new URL architecture, I need to redirect old URLs because I am getting lot of 404.

Old URL examples:
domain.com/blog/vse-o-produktech/395-vybaveni-a-doplnky-pro-vasi-pergolu
domain.com/blog/71-prave-realizujeme/464-kdo-nainstaloval-pergolu-dominiku-haskovi-jagr

New URL:
domain.com/vybaveni-a-doplnky-pro-vasi-pergolu
domain.com/kdo-nainstaloval-pergolu-dominiku-haskovi-jagr

So red parts need to be removed.


I have tried put this REGEX to my .htaccess:
blog/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)/[0-9]+-
like this:
<IfModule mod_rewrite.c>

RewriteCond %{THE_REQUEST} ^GET\ /blog/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)/[0-9]+-
RewriteRule ^blog/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)/[0-9]+- $1 [L,R=301]

</IfModule>

But it does not work. In online regex tester tools (like regextester.com) it works.

If you can made up valid code I will pay you $10
I will have more jobs like this, so we can colab to the future.
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock