Help please, I spent 4 hours already so and it didn't work out ((

There are links of the form /catalog/razdel1/razdel2 , etc. at the end /ID/ ID - numbers, 4-5 characters

It is necessary to get links for all such links of the form /catalog/view/ID/ . But either it doesn’t work, or cyclic redirects are coming (

tried this:

 RewriteCond %{REQUEST_URI} !^catalog/view/$ RewriteRule ^(.*)/([0-9]*)/(.*)$ /catalog/view/$2/$3 [R=301,L] 

so

 RewriteCond %{REQUEST_URI} ^(.*)/([^view]*)/([0-9]*)/(.*)$ RewriteRule (.*) /catalog/view/%3/%4 [R=301,L] 

Tell me how to do it right! Thank!

Place in htaccess where editing takes place

 <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On #RewriteRule ^catalog/(.*)/([0-9]*)/(.*)$ catalog/view/$2/$3 [R=301] #RewriteCond %{REQUEST_URI} ^(.*)!view/(.*)/([0-9]*)/(.*)$ RewriteCond %{REQUEST_URI} !^catalog/view$ #RewriteCond %{REQUEST_URI} ^(.*)/([0-9]*)/(.*)$ RewriteCond %{REQUEST_URI} ^(.*)/([0-9]*)/(.*)$ #RewriteRule ^(.*)/([0-9]*)/(.*)$ /catalog/view/$2/$3 [R=301,L] RewriteRule ^(.*)$ /catalog/view/%2/%3 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$ RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L] RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}] </IfModule> 
  • Show an example of a complete link yoursite.com?id=12& ..... - L. Vadim
  • yoursite.com/catalog/phones/samsung/4396/ or yoursite.com/catalog/phones/accsesuar/samsung/4396/ need to get yoursite.com/catalog/view/4396/ numbers of course all different)) and links after catalog / also! - AzraEL
  • What is a CMS? and if you can .htaccess pokozat old - L. Vadim
  • Bitrix of course) and it’s necessary to get rid of duplicate pages, but in the search when people clicked on the old links the redirect was to the new htaccess standard bitrix the whole point I don’t see only where to change it - AzraEL
  • you already have .htaccess in your system, so you need to edit it. - L. Vadim

1 answer 1

Right after

 RewriteEngine On 

prescribe

 # пропускаем ссылки начинающиеся на /catalog/view RewriteCond %{REQUEST_URI} !^/catalog/view # захватываем номер из ссылок вида /catalog/1иБольшеСимволовНеСлэшей/1иБольшеСимволовНеСлэшей/1иБольшеЦифра/ RewriteCond %{REQUEST_URI} ^/catalog/[^/]+/[^/]+/(\d+)/$ # делаем редирект на /catalog/view/ЦифрыКоторыеЗахватили/ RewriteRule . /catalog/view/%1/ [R=301,L] 
  • THANK YOU VERY MUCH!!!! slightly corrected that not only 2 nesting were taken into account)) RewriteCond% {REQUEST_URI} ^ / catalog / [^ /] + / (. *) / (\ d +) / $ that is, if anyone needs to redirect from / catalog / razd1 / razd2 / razd3 / razd4 and so on. until at the end there will be tsiferok! - AzraEL