PHP假网址,复杂.htaccess rewrite_mod

I have real a lot about CakePHP, and php rewrite_mod, but i m so much confused about how to use it as i don't have knowledge about regex. how can i have something like this?

mywebsite.com/en/ => mywebsite.com/?lang=en

mywebsite.com/en/about => mywebsite.com/about/?lang=en

mywebsite.com/en/search/?query=Hello+World => mywebsite.com/search/?query=Hello+World&lang=en

so in the reality my files are like:

public_html/about/index.php
public_html/search/index.php
public_html/index.php

but i m faking it like

public_html/en/about/index.php
public_html/en/search/index.php
public_html/en/index.php

and need to conserve the URL, and PARAMETERS passed through GET, i don't understand how to setup a so complex url controller in .htaccess

i've also tried following this but not getting out, is there any sample project? cakephp 3 parameter url

Essentially, you rearrange the request URL. This means, you must capture (...) the parts separately, and put them together in the substitution $.... You also want to keep an existing query string, which requires the use of the QSA|qsappend flag. The RewriteCond is there to prevent a rewrite loop. If the rule was applied once, it shouldn't be used a second time.

RewriteCond %{QUERY_STRING} !lang=
RewriteRule ^(..)(.*)$ $2?lang=$1 [L,QSA]

To learn more about regular expressions, see Apache - Regular Expressions.