B
B
Bogdan Gerasimenko2017-01-30 01:52:13
Regular Expressions
Bogdan Gerasimenko, 2017-01-30 01:52:13

Question about htaccess regular expressions?

Hello,
You need to make a redirect for categories, for example:
https://mysite.ru/123-catsto https://mysite.ru/shop/cats
and from the product page, for example:
https://mysite.ru/cats/834-whiskas.htmlto https://mysite.ru/product/whiskas
Tell me what the RewriteRule will look like for these two rules

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2017-01-30
@Kleindberg

At
you have a cyclic redirect, because /product/$1 matches regex ^/.*/([0-9]-.*\.html)$
you need to make stricter rules..

RewriteCond %{REQUEST_URI} !^/product [NC]  # если не начинается с /product
RewriteRule ^/.*/([0-9]-.*\.html)$ /product/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question