L
L
lexchz2016-03-02 18:13:26
htaccess
lexchz, 2016-03-02 18:13:26

How to form the end of the url of the redirected page?

For subcategory redirect it says:

RewriteRule ^ekonomia/svyaz/?(.*)$ http://site.ru/svyaz/$1 [R=301,L]

The problem is that if the slug of an article in the ekonomia category starts with svyaz, for example svyaznoi, then the redirected link looks like this:
http://site.ru/svyaz/noi
And it should be site.ru/ekonomia/svyaznoi. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-03-03
@lexchz

Use negation!

RewriteCond %{REQUEST_URI} !^ekonomia/svyaz/svyaz.*$ [NC]
RewriteRule ^ekonomia/svyaz/?(.*)$ http://site.ru/svyaz/$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