I want to install WP in 3 languages: en, ro, ru


I was not sure, but installed WP in the root folder.

Now I need to redirect visitors to default language. Say "en". AND I don't need having 4 sites actually: /, /en/, /ro/, /ru/, but 3.

The situation is actually like this

I can't "remove" the "/" site, actually

  • Do you really want different websites for each language? Why dont you use WPML plugin instead? – sorin Nov 1 '10 at 6:30
  • @Sorin Sbarnea WPML plugin is a plugin with bugs. And it does not translates the images on themes. – serhio Nov 2 '10 at 2:21

I use on the root site a small theme for redirect to the languages. A very small theme for locate the language of the users and redirect to the blog of this language.

// Browsersprache ermitteln
function lang_get_from_browser($allowed_languages, $default_language, $lang_variable = NULL, $strict_mode = TRUE) {
    // $_SERVER['HTTP_ACCEPT_LANGUAGE'] verwenden, wenn keine Sprachvariable mitgegeben wurde
    if ( NULL === $lang_variable )
        $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];

    // wurde irgendwelche Information mitgeschickt?
    if ( empty($lang_variable) ) 
        return $default_language;

    // Den Header auftrennen
    $accepted_languages = preg_split('/,\s*/', $lang_variable);

    // Die Standardwerte einstellen
    $current_lang = $default_language;
    $current_q    = 0;
    // Nun alle mitgegebenen Sprachen abarbeiten
    foreach ($accepted_languages as $accepted_language) {
        // Alle Infos dieser Sprache rausholen
        $res = preg_match(

        if (!$res)

        // Sprachcode holen und dann sofort in die Einzelteile trennen
        $lang_code = explode('-', $matches[1]);

        // Wurde eine Qualität mitgegeben?
        if ( isset($matches[2]) )
            $lang_quality = (float)$matches[2];
            $lang_quality = 1.0;

        // Bis der Sprachcode leer ist...
        while (count ($lang_code)) {
            // mal sehen, ob der Sprachcode angeboten wird
            if (in_array ( strtolower( join('-', $lang_code) ), $allowed_languages) ) {
                // Qualität anschauen
                if ($lang_quality > $current_q) {
                    $current_lang = strtolower( join('-', $lang_code) );
                    $current_q = $lang_quality;
            // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren
            if ($strict_mode)

            // den rechtesten Teil des Sprachcodes abschneiden

    return $current_lang;

$allowed_langs = array('en', 'de');
$lang = lang_get_from_browser($allowed_langs, 'en', NULL, FALSE);

if ( 'de' === $lang )
    Header("Location: http://wpbasis.de/readme-de_DE.php");
    Header("Location: http://wpbasis.de/readme-en_US.php");
  • Thanks! Would you be so kind to translate your comments to English? I don't need them but I don't want to include non-English comments in any of the files, it not good for maintenance. Also the solution could be adapted to use the languages defined in WordPress instead of harcoding them. – sorin Nov 1 '10 at 13:59
  • I will write my code in a theme for free, then its all in english. – bueltge Nov 1 '10 at 17:04
  • yeah. English comments rulles. Even If I am not a native English Speaker, I try to comment in English my code :) But, I don't understand, why this code you name "theme". Where should I find such a theme? – serhio Nov 2 '10 at 2:31
  • i create a theme for WordPress in root blog for rewrite, current i write a theme for this. – bueltge Nov 2 '10 at 19:02
  • 1
    @bueltge: To stay with the comment language: Na das ist ja einmal gewaltig geil! – kaiser Mar 25 '11 at 14:06

just leave it and place a redirect on it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.