Redirecting all pages under a certain directory to a single file I want to redirect all pages under a certain directory to a single file, like so:


/dir/a → /dir/new
/dir/b →  /dir/new
/dir/new →  /dir/new


With the straightforward

RedirectMatch 301 ^/dir/ http://example.com/dir/new


I get a redirect loop, since /dir/new redirects to itself. I replaced it with a regular expression

RedirectMatch 301 ^/dir/($|[^n]|n$|n[^e]|ne$|ne[^w]|new.) http://example.com/dir/new


which matches all URLs except the desired one. This works, but it's obviously the 'wrong' way to do it. What's a better way?
It seems you're looking for a negative lookahead:
path starting with /dir/ and not followed by new$:

RedirectMatch 301 ^/dir/(?!new$) http://example.com/dir/new