R
R
Ruslan Banochkin2015-10-08 09:41:47
htaccess
Ruslan Banochkin, 2015-10-08 09:41:47

How to redirect categories with htaccess without redirecting subpages?

Greetings.
Can't implement the following. It is necessary that when you go to the site.ru/gallery/ page, a 301 redirect to the site.ru/category/gallery/ page occurs.
Did the following:
Redirect 301 /gallery/ /category/gallery/
But now there is a problem. When you go to a nested page, for example site.ru/gallery/post.html, there is a redirect to site.ru/gallery/category/post.html, but this is not necessary.
The question is - how to make a 301 redirect from /gallery/ to /category/gallery/, but without subpages?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShamblerR, 2015-10-08
@Sk8er

You just need to limit it with a more stringent condition, in fact, one condition is enough for you, but I wrote two to be sure.

RewriteCond %{REQUEST_URI} ^(gllery)/$
# условие если урл содержет начало строки гелерик -конец строки
RewriteCond %{REQUEST_URI} !.*\.php$
# доп условиен на всякий случай если урл НЕ заканчивается на php
RewriteRule ^(.*)$  http://site.ru/category/gallery/ [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question