Rewrite variable to folder
===

I need to rewrite an URL with .htaccess.

    (Actual url) Before: yyy.com/folder/index.php?lang=en
    (Their url)  After:  yyy.com/folder/en/index.php
    
    Before: yyy.com/folder/submit.php?lang=da
    After:  yyy.com/folder/da/submit.php

How do I do this?