Looks like in Joomla there is a better way to solve this issue than using mod_rewrite. A big advantage seems to be that you do not have to rely only on the Apache server, i.e. if you want to use nginx.
Here some links I found on how to write a Custom Router in Joomla:
For Joomla 4
For Joomla 3
If you know of better tutorials, feel free to post your links to this topic.
Edit: This thread should also be helpful: Joomla 4 Router forward to Controller function