What's the easiest way to convert these requests:
http://www.example.com/en/
http://www.example.com/en/index.php
To:
http://www.example.com/index.php?language_id=en
There's various PHP files, so the rule would also need to map
http://www.example.com/en/anyfile.php
To:
http://www.example.com/anyfile.php?language_id=en
The language ID can be any two letter code (it's checked within the PHP script, to ensure it's valid).
Presumably, I'll need to use .htaccess, and any advice on how to implement the above would be greatly appreciated. Thanks.
Update
The following worked for me.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-z]+)/(css|js|images)/(.+) /$2/$3 [L]
RewriteRule ([a-z]+)/(.+).php /$2.php?language_id=$1 [QSA,L]
RewriteRule ([a-z]+)/$ /index.php?language_id=$1 [QSA,L]
</IfModule>
This also re-routes requests to the css, js, and images folders back to the root folder. It also works if no filename is entered, automatically redirecting to index.php.