Sitemap Issue with mappings

Enonic version: 6.15.8
OS: macOS Catalina

We are facing issues with Sitemap.xml which are dynamically generated using mappings just as suggested in Dynamically created sitemap.xml.

we have multiple sites, it works for all but two sites which are placed under a folder like folder/site and folder/site-en. we have two mapping-patters with the same controller to support the sites under the folder and sites which are not.
<pattern>/site/sitemap.xml</pattern> and <pattern>/sitemap.xml</pattern>

This setup used to work earlier. but recently it’s giving 404.