Support » Plugin: Multisite Language Switcher » URL Structure Problem

  • Resolved andaluzo



    first great work and thanks!
    Where is the donate button 🙂

    Actually i have installed and everything works fine so far.

    I have one issue.

    As I want consistant URLS


    I realy do not like to use the root / for any language. But User type the direct URL so what to do with that part of the network, is there any way to redirect by default o by User language to one of the network sites?

    That would be great !

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Dennis Ploetner


    Seems something like this:


    Plugin Author Dennis Ploetner


    Is this problem resolved now?

    BTW There is a donate button which points to … 😉

    I resolved it with

    putting the following as index.php in the template for ‘/’

     * The main template file.
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     * Learn more:
     * @package WordPress
     * @subpackage Redirect
     * Detect browser language.
     * @param array $allowed_languages An array of languages that are available on the site.
     * @param string $default_language Default language to use if none could be detected.
     * @param string $lang_variable Custom user language support. If not specified $_SERVER['HTTP_ACCEPT_LANGUAGE'] is used.
     * @param string $strict_mode If true (default) the whole language code ("en-us") is used and not only the left part ("en").
     * @return string The detected browser language.
    function get_lang_from_browser($allowed_languages, $default_language, $lang_variable = NULL, $strict_mode = TRUE) {
        // Use $_SERVER['HTTP_ACCEPT_LANGUAGE'] if no language variable is available
        if (NULL === $lang_variable)
            $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
        // Any info sent?
        if (empty($lang_variable))
            return $default_language;
        // Split the header
        $accepted_languages = preg_split('/,\s*/', $lang_variable);
        // Set default values
        $current_lang = $default_language;
        $current_q    = 0;
        // Now work through all included languages
        foreach ($accepted_languages as $accepted_language) {
            // Get all info about this language
            $res = preg_match(
            if (!$res)
            // Get language code and split into parts immediately
            $lang_code = explode('-', $matches[1]);
            // Is there a quality set?
            if (isset($matches[2]))
                $lang_quality = (float)$matches[2];
                $lang_quality = 1.0;
            // Until the language code is empty...
            while (count($lang_code)) {
                // Check if the language code is available
                if (in_array(strtolower(join('-', $lang_code)), $allowed_languages)) {
                    // Check quality
                    if ($lang_quality > $current_q) {
                        $current_lang = strtolower(join('-', $lang_code));
                        $current_q = $lang_quality;
                // If we're in strict mode we won't try to minimalize the language
                if ($strict_mode)
                // Cut the most right part of the language code
        return $current_lang;
    $allowed_langs = array('en', 'de', 'es');
    $lang = get_lang_from_browser($allowed_langs, 'en', NULL, FALSE);
    header('Location: http://' . $_SERVER['HTTP_HOST'] . "/$lang/");

    If you generate it as blank theme you should also put some styles.css in that Theme folder.

    Works great, seams to be German engineering your plugin 🙂

    Plugin Author Dennis Ploetner


    Yes, your solution is similar to the solution I linked in my first answer. The default blog gets a theme which makes nothing else than forwarding a user.

    And yes, I’m German (but live in Milan). 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘URL Structure Problem’ is closed to new replies.