A
A
Anton2015-09-14 08:23:14
System administration
Anton, 2015-09-14 08:23:14

How to redirect part of url?

Hello! Some keywords in the URL have changed a bit on the site and we need to redirect from old links to new ones.
Example:

http://example.org/category/  -> http://example.org/categoria/
http://example.org/category/product/  -> http://example.org/categoria/tovar/
http://example.org/info/  -> http://example.org/informatcia/

Tried to do with RewriteRule:
RewriteRule ^category /categoria [L]
Or
RewriteRule ^category/(.*) categoria[L]
But for some reason nothing works.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2015-09-14
@IceJOKER

RewriteEngine on
RewriteRule ^category$ /categoria [R=301,L]
RewriteRule ^category/product$ /categoria/tovar [R=301,L]
RewriteRule ^info$ /informatcia [R=301]

D
Dmitry Samanev, 2015-09-14
@samanev

RewriteEngine On
RewriteBase /
## Два выражения выше уже должны быть в идеале ##
## Обычные 301е редиректы на категории
Redirect 301 /category/  http://domen.dom/categoria/
Redirect 301 /info/ http://domen.dom/informatcia/

## Редирект на все товары подкатегории
## Работает в случае, если categoria находится в корне (http://domen.dom/categoria/)
RewriteCond %{REQUEST_URI} ^(.*)(\/category\/)(\S+)$
RewriteRule ^(.*)$ categoria\/%3 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question