D
D
doutaxe2019-03-26 11:44:11
htaccess
doutaxe, 2019-03-26 11:44:11

How to make a 301 redirect in .htaccess with the substitution of a part of the URL?

I'm trying to make a 301 redirect in .htaccess like this:
https://example.ru/catalog/strana-gorod-{123}-{456}/
->
https://example.ru/strana/gorod/
Where:
{123} - a certain predefined character set (only pages containing {123} should be redirected)
{456} - any character set
With the help of google and examples, I can cut /catalog/ from the URL, I can cut {123}-{456}, but the rest I don’t know how to convert part of the URL. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-03-26
@doutaxe

RewriteRule ^catalog/(strana)-(gorod)-.*/$ /$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