P
P
Petr Volkhanov2015-02-17 05:19:48
htaccess
Petr Volkhanov, 2015-02-17 05:19:48

How can I correctly write a RewriteRule for such a condition?

There is an ulr like site.ru/tovar/semena-ovoschey/semena-arbuza/vostochnyj-ornament. How can I correctly write the RewriteRule to get site.ru/semena-ovoschey/semena-arbuza/vostochnyj-ornament?
Tried like this:
RewriteRule ^product/(.*)$ $1 [R=301, L]
But this rule doesn't work!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
ShamblerR, 2015-02-18
@eprivalov

You have a cyclic request.
Because redirects will work again and again until after passing through .htaccess, no url changes.
In your case, you need to set the first condition more strictly.
like this

RewriteCond %{REQUEST_URI} !^semena-ovoschey.*$ 
RewriteCond %{REQUEST_URI} ^tovar/(.*)$ 
RewriteRule ^tovar/(.*)$ $1 [R=301, L]

In this case, two conditions will be checked at once.
! - negation
^- start of line

M
Max Razdobudko, 2015-02-17
@0b10111

Eugene, try looking for the answer here: blog.aweb.ua/301-redirect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question