A permalink pattern for collections, excluding the very first level folder from url

I have this folder structure for my collection docs:

_my_collection/
└── subdir1
    └── subdir2
        └── doc.md

Is there a way to achieve /subdir2/doc.html url for doc.md by defining a permaling configuration in _config.yml file?

_my_collection/
└── subdir1
    └── subdir2
        └── subdir3
            └── doc.md

I would like this structure to be rendered at /subdir2/subdir3/doc.html