O
O
on_click2019-12-23 02:23:20
htaccess
on_click, 2019-12-23 02:23:20

How to set up a redirect from /cat/length-20-40/page2 to /cat/length_20-40/page2?

Greetings
, please tell me how to make an automatic 301 redirect,
if the address contains the substring 'length-' to the same address with the replacement of the substring with 'length_'
There are a lot of pages, with different levels of nesting

/cat/length-20-40/page2  -> /cat/length_20-40/page2
/cat/length-20-40        -> /cat/length_20-40
/length-20-40/page2      -> /length_20-40/page2

I honestly re-read all similar questions, it seems the task is simple, but everywhere they write about a redirect from www and the like, and there are no working answers in those close to mine (or I didn’t find them)
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-12-23
@on_click

RedirectMatch 301 ^/(.*length)-(.*)$ /$1_$2
Or

RewriteEngine On

RewriteRule ^(.*length)-(.*)$ /$1_$2 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question