Multisite use language code as subdirectory

I installed WordPress in the subdiretory /de and activated multisite features. The main blog has the URL/path: mysite.de/de

Now I want to add a second site for the English language with the following url: mysite.de/en

Read More

But after I added the site, the subdirectory for the English site was set as:
mysite.de/de/en

Any ideas how I can get these site urls?

mysite.de/de
mysite.de/en
mysite.de/fr

Related posts

Leave a Reply

2 comments

  1. Here’s a proper multisite solution:

    Install WordPress directly on the root of your domain mysite.de. After that, setup a multisite and chose the subdomain option (Yes, subdomain! It’s far more flexible and you can use it with subdirectories as well).

    WordPress will ask you to update wp-config.php and .htaccess. To the wp-config.php add the following constants (in addition to the one provided by WP)

    define( "COOKIEDOMAIN", "" );
    define( "ADMIN_COOKIE_PATH", "/" );
    define( 'SITECOOKIEPATH', '/' );
    

    Don’t use the .htaccess code provided by WordPress but use instead this one:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
    RewriteRule . index.php [L]
    

    Go to the network admin menu and create two sites, one for each language. You will get asked for the site address (subdomain). Just enter de for the German site and en for the English one. After the site has been created, edit it directly. Now you can edit the complete URL. Just set it to http://mysite.de/de and http://mysite.de/en. Do this for the French site as well.

    Now you have four sites in your network, probably with the following IDs:

    1 mysite.de/
    2 mysite.de/de
    3 mysite.de/en
    4 mysite.de/fr
    

    As you don’t need the first one, you can leave it just empty. You just don’t use it. Manage your content in the other thre sites.

    To redirect requests to mysite.de/ add another line to your .htaccess above the others:

    RedirectMatch permanent "^/$" http://mysite.de/de
    

    You now have a full functional network of two active sites for your content.

    Finally a personal recommendation: There’s a free plugin called Multilingual Press that supports this concept of a multilingual setup in a network. Disclosure: I contributed to this plugin before and working for a company that develops this plugin.

  2. It would be far easier to maintain the blog by using a good WordPress translation plugin.

    WPML (http://wpml.org) is my favourite plugin for the task. If you prefer not to pay anything QTranslate is also a good option.

    Both plugins allow you to have sub domains (en.mysite.de) or language folders (mysite.de/en).

    Best of luck!