totoaussi totoaussi - 3 months ago 10
Apache Configuration Question

.htaccess : how to redirect folder to his subfolder?

I have a web page and his url is http://wwww.example.com/category/door/

But I want to redirect (301) the http://www.example.com/category/ to http://www.example.com/category/door/ because the content of http://www.example.com/category/ is empty.

My rewrite rule is the follow :

RedirectPermanent /category/ /category/door/


But it doesn't work, because the browser redirect http://www.example.com/category/ to http://www.example.com/category/door/door/door/door/door/door/door/door/ infinitely.

An idea ? Thank you.

Answer

Try this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/category/door
RewriteRule ^category/$ /category/door/ [QSA,L,R=301]