B
B
basilesan2014-08-07 16:05:08
htaccess
basilesan, 2014-08-07 16:05:08

RewriteRule how to write a rule "in reverse"?

The essence of the problem - there were URLs like
site.ru/collection/category/item/?color=5347
After the introduction of CNC using the CMS mechanism, the URLs became:
site.ru/collection/category/item/color5347
"category", "item" , 5347 - variables
How to write a RewriteRule for htaccess to get 301 redirects from old URLs to new ones?
In all examples, the situation is exactly the opposite - from the CNC page, a redirect to a page with GET parameters, which does not make it possible to find any sensible solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
basilesan, 2014-08-07
@basilesan

I decided myself.

RewriteBase /
  RewriteCond %{QUERY_STRING} ^(.*&)?color=([0-9]+)(&.*)?$ [NC]
  RewriteRule ^(.*)$ $1color%2/? [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question