Manply
Manply

Reputation: 75

.htaccess redirection subdirectory to other ERR_TOO_MANY_REDIRECTS

I need redirects from a subdirectory to go to the root, example:

example.com/test/aaa

example.com/test/bbb

We need redirect to example.com/test

I have created the next redirect:

Redirect 301 example.com/test/aaa example.com/test/

And I'm getting ERR_TOO_MANY_REDIRECTS error

What is the best solution for this problem? Like example.com/test/# go to example.com/test/

Upvotes: 1

Views: 78

Answers (1)

anubhava
anubhava

Reputation: 785631

Use RedirectMatch with a regex to be able to match both sub-directories in same rule:

RedirectMatch 301 ^(/test/)(?:aaa|bbb) $1

Make sure to clear your browser cache before testing.

Upvotes: 2

Related Questions