Where is RewriteMap allowed?

According to the official documentation it's only allowed in the scope (Context: in the infobox) of server config, virtual host. Place it outside the directory directive and it will work.