Redirecting all subdirectories of a folder through htaccess

This question already has an answer here:

I have searched around and I have not found this specific question asked.

I need to redirect everyone the & # 39; subfolders & # 39; from a directory to the parent directory.

For example, the parent directory is example.tld / directory and all subdirectories like example.tld / directory / subdirectory-1 and example.tld / directory / subdirectory-2 everyone needs to redirect to example.tld / directory

To clarify, these are not real directories but secondary routes of Drupal, but I think it should work to do it through htaccess.

Just to be clear, the URLs.

example.tld / directory / subdirectory-1

example.tld / directory / subdirectory-2

etc …

everyone should redirect to

example.tld / directory

The idea is to make these subdirectories inaccessible to anyone and make sure that search engine crawlers do not index these subdirectories.

What would be the correct access code to achieve this?