The problem I'm facing with .htaccess is that I want to pass the first segment of URL as a $_GET parameter so that for example www.example.com/en/ reads as www.example.com?language=en and www.example.com/category/groceries/?language=en reads as www.example.com/en/category/groceries , i want this to be done for all php pages without writing a rule for every page here is what i tried without success
RewriteEngine on
RewriteRule ^en$ ?language=en&%{QUERY_STRING} [NC,L,QSA]
RewriteRule ^ar$ ?language=ar&%{QUERY_STRING} [NC,L,QSA]
However this doesn't work as intended