Multilanguage Contentblock, mod_rewrite

Permalink
hi, I'am developing a multilanguage Contentblock. The biggest work is done and it works quite well so far. The way I'am, doing that, is to store content in an xml format to the database. This has the advantage of no double content hierachies and you don'd need constructions like these

if($language == 'english')
{
   $a = new Area('Main');
   $a->display($c);
}
if($language == 'german')
{
   $a = new Area('Inhalt');
   $a->display($c);
}



I need help for rewriting rules, that's a big blackbox for me. I would like to have the .htaccess file so modular as possible to reuse in other projects. The hierarchy, in concrete5, looks like this. All content is under the "de" branch

root
      de
        contact
        impressum
        news 
        content 
     en
     es

my example url, to demonstrate my requirements for modrewrite.

http://server/index.php/de/contact...


1. remove index.php from URL (that rewriterule is build in concrete5)

after that the URL Looks like thesehttp://server/de/contact

2. get the 2. parenthesis to store the language in enviroment environment variable

something like that [E=MYLANGUAGE:$2] so i can evaluate $_SERVER['MYLANGUAGE'] in my multilanguage block

3. if the users URLhttp://server/es/contact

root intern tohttp://server/de/contact because all content is under the de branch and show the userhttp://server/es/contact

Is there someone who can help me?

1 Attachment

wrongspot
 
wrongspot replied on at Permalink Reply
wrongspot
okay, I answer myself :)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(de|en|ru|es)/(.*)$ index.php/de/$2 [E=MYLANGUAGE:$1,L]
</IfModule>


these rewrite rules meets my requirements. You can access the enviroment variable over $_SERVER['REDIRECT_MYLANGUAGE'].