Fix my .htaccess rewrite REGEX code (simple)

Status
Not open for further replies.

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.
 
Status
Not open for further replies.
This thread has been auto closed due to the forum's thread age policy. Read more.
Back
Top