A
A
Andrey Ivanov2020-01-29 12:38:21
MODX
Andrey Ivanov, 2020-01-29 12:38:21

How to make a mass redirect to the 2nd level of nesting?

Hello! Please help:

Is it possible to somehow make a mass redirect to the 2nd level of nesting? On MODX they made url nesting up to the 2nd level (no subcategories). But the pages before that were indexed with the full url, so when you go to them, we get 404.

You need to do the following:
from site.ru/catalog/subcatalog/product redirect to site.ru/product

The problem is that nesting can be different. And a lot of pages.

Somehow via htaccess or maybe a plugin?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-01-29
@dv1zhok

RewriteCond %{REQUEST_URI} ^/catalog/subcatalog/(.+)$ 
# если строка начинается с /catalog/subcatalog/product/ 
RewriteRule ^(.*)$ /%1 [R=301,L]

where %1 is the parenthesis from RewriteCond

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question