it is probably a stupid question, but I have real troubles figuring out, how to redirect

/products to /products/item

It is a simple redirect, no regex needed. The toplevel site /products should just always redirect to /products/item

I tried:

<IfModule mod_rewrite.c>
RedirectMatch 301 /products(.*) /products/item/$1

I receive the error, that the webserver is redirecting in an infinite loop. That might be because of the rest of the htaccess file. Which looks like that:

# Custom Rules
<IfModule mod_rewrite.c>
RedirectMatch 301 /products(.*) /products/item/$1

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

But the strangest thing: When I load the page, I get the error. When I then hit reload, it works???

Thanks for your help! ole

2 Answers 2


If you just want to redirect /products to /products/item, this should work:

RedirectMatch 301 ^/products/?$ /products/item

The ^ and $ characters anchor the regular expression to the beginning and end of the path, so that it won't match /foo/products or /products/bar. The /? allows it to match both /products and /products/; you can remove it if you don't want that.


The (.*) after products is what's causing the loop. It redirects /products/something to /products/item/something, but then that has to be redirected to /products/item/item/something etc.

You need to exclude item so this may work:

RedirectMatch 301 /products/(?!^item)(.*) /products/item/$1

This means redirect /products/something except something beginning /products/item.

  • Thank you, but I don't want to redirect /products/something, I want to redirect /products/ one level deeper to /products/item . Any thoughts on that?
    – ole_berlin
    Feb 8, 2012 at 15:36
  • I thought that because you had the (.*) and the $1 in your file. That's what they are there for. In that case Ilmari's answer is what you need. Feb 8, 2012 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.