G
G
GSA2016-03-31 20:01:40
htaccess
GSA, 2016-03-31 20:01:40

How to implement 301 redirect for rules?

For the first time I come across a redirect and it is difficult to imagine its capabilities. Therefore, the next question)
The site was transferred from joomla to bitrix.
1) If the link contains "/magazin/browse/manufacturer/", then replace it with "/manufacturer/"
2) If the link contains "/magazin/category/product/", then replace it with "/catalog/product/" and delete the content until the next "/"
3) If the link contains "/magazin/category/manufacturer/#SECTION_CODE#/#XML_ID#.html", then form the link "/catalog/#SECTION_CODE#/filter/brands_ref-is- #XML_ID#/apply/"
4) If the link contains "/magazin/category/", then replace it with "/catalog/"
Will these rules conflict with each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-04-01
@shambler81

No, they won't if you hardcode the logic.
For the sweet life
https://donatstudios.com/RewriteRule_Generator
Your question

RewriteCond %{REQUEST_URI} ^(.*)/dir1/(.*)$ 
# если строка содержит /dir1/ 
RewriteRule ^(.*)$ %1/dir2/%2 [R=301,L] 
#Перенаправить все урлы с начинающиеся с dir1 на dir2 с сохранением дальнейшей структуры URL

But as I understand it, you ONLY need the page /magazin/browse/manufacturer/ and not all that start with /magazin/browse/manufacturer/
So limit
(/|) - or with a slash
$ - the end of the line
And the question that appears you then
how to exclude a certain page and redirect the rest
. Negation works absolutely for all logic
RewriteCond %{REQUEST_URI} ^(.*)/magazin/category/manufacturer(/|)$ 
RewriteCond %{REQUEST_URI} !^/magazin/category/manufacturer/#SECTION_CODE#/#XML_ID#.html$ 
RewriteRule ^(.*)$ %1/dir2/%2 [R=301,L]

And that:
If url
if does not contain
Then

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question