.htaccess add hidden php get variable for language selection
- by Eric Di Bari
I have a multiple language website, and I use a php get variable to set the cookie for the language setting. I have multiple subfolders (http://www.site.com/es and http://www.site.com/de) that each have a respective .htaccess file. When accessing these folders, the .htaccess file does this to "silently" redirect the user and add the appropriate php variable:
-------
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
rewriterule ^http://www.site.com/es/$ http://www.site.com/?l=es [P,R=301]
rewriterule ^(.*)$ http://www.site.com/$1?l=es [P,R=301]
-------
When someone accesses the root directory: http://www.site.com, I want to add a ?l=en suffix "silently" to the url. How do I do that? Thanks.