Based on the your input, I would suggest using URL rewriting configuration as follows:
RewriteEngine on
RewriteRule ^([a-zA-Z-_]+)$ $1.php?lang=en [R]
RewriteRule ^([a-z]+)/([a-zA-Z-_]+)$ $2.php?lang=$1 [R]
The first rule rewrites URLs like /abc
(with no specified language) to /abc.php?lang=en
and sets English (en
) as a default language
The second rule rewrites URLs like /xy/abc
(with specified language) to /abc.php?lang=xy
(language is taken from the first part of the request URL)
Examples:
http://mydomain.com/en/references => http://mydomain.com/references.php?lang=en
(RewriteRule #2)
http://mydomain.com/ro/referinte => http://mydomain.com/referinte.php?lang=ro
(RewriteRule #2)
http://mydomain.com/references => http://mydomain.com/references.php?lang=en
(RewriteRule #1)
http://mydomain.com/referinte => http://mydomain.com/referinte.php?lang=en
(RewriteRule #1)
Please note that the rules will ignore requests for specific PHP
files i.e. requests as follows: http://mydomain.com/ro/referinte.php
or http://mydomain.com/referinte.php
will not be rewritten. Also, server response should be the same for non-existing pages as currently i.e. assuming /referinte.php
does not exist, the requests as follows: http://mydomain.com/en/referinte
(new rewriting) and http://mydomain.com/referinte?lang=en
(current rewriting) I presume would return 404.
I hope that will help.