I need to have an unilateral function in mod_rewrite which giving a path produce a prefix using only a regex, unfortunately I have no control whatsoever on implementing this system.
I can only produce a regex and give it to the system administrator.
What I need is a regex pattern which is reducing a path in a two char prefix as follows
I saw that there is a tester on regrex for mod_rewrite here
You may use these rules in site root .htaccess:
RewriteEngine On
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(\w)\w*[.-](\w)\w*/?$ /$1$2 [L,R=301]
RewriteRule ^(\w)[\w-]*\.(\w) /$1$2 [L,R=301]
RewriteRule ^(\w)(\w)[^.-]+$ /$1$2 [L,R=301]