K
K
kelya942019-08-27 15:47:55
htaccess
kelya94, 2019-08-27 15:47:55

Redirecting product pages to Bitrix and cyclic redirection?

There are product pages: https://site.ru/katalog/ section -name /product-name/
And brand pages: https://site.ru/katalog/ section -name /brand-brand-name/ It is
necessary to redirect the products to this format: https://site.ru/katalog/ product /product-name/ I
wrote a redirect like this:
RewriteRule ^(.*)katalog/(.*)/(.*)/$ https://site.
ru/ katalog /product/$3/ [R=301,L] redirect from katalog to katalog
How can I solve this problem without affecting brand pages?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-08-27
@kelya94

RewriteRule ^katalog/(?!product/)[^/]+/(?!brand-)([^/]+)/$ https://site.ru/katalog/product/$1/ [R=301,L]

Or
RewriteCond $2 !=product
RewriteCond $3 !^brand-
RewriteRule ^(katalog)/([^/]+)/([^/]+)/$ https://site.ru/$1/product/$3/ [R=301,L]

V
Viktor Taran, 2019-08-27
@shambler81

the product page cannot be in the "brand" category because it can be linked to several categories at once.
For example:

карсный /  для дома/ две дверцы/1товар
зеленый /  для дома/ две дверцы/1товар
Холодильник /   дешевый/размер 1x2/  две дверцы/ со скидкой
Встраиваемый/товар
И тд

As you understand, all this is the category to which it is attached
And the url naturally cannot be like this since this is a cannibalization of requests not a unique url, etc., etc.
And it should be like this
/catalog/1product
In this case, all sections will be built in sections and the product will always have one url, and the shortest possible, ideally /1product, but this is not a standard for Bitrix.
And what you did is a hat.
Of the bad URLs, you have collected even worse, and in addition, you have also lost the weight of the page, since 301 almost does not transmit it, for 5 years already. If it does, it transmits only a small part. PF is out in the yard.
Now the answer
RewriteCond %{REQUEST_URI} !katalog/product$
RewriteRule ^katalog/(.*+[^/])/(.+[^/])/$ https://site.ru/katalog/product/$2/ [R=301,L]

Condition if RewriteCond
! - denial

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question