I have similarly coded inefficient rules in my httpd.conf.
For example I have the following rule to 404 any request to a certain directory which has more than 4 further subdirectories
RewriteRule ^/dir1/.+/.+/.+/.+/.+$ /404 [R=404,L]
I think I can code it more efficiently as follows :
RewriteRule ^/dir1/[^/]+/[^/]+/[^/]+/[^/]+/.+ /404 [R=404,L]
(I think I should also change [^/]+ to [^/]* in order to catch consecutive slashes).
But is there a neater and more efficient alternative ?