0

Is it possible to install a multisite and have the first installation here:

http://www.example.com/en/blog/

and then all other sites in these places?

http://www.example.com/cn/blog/

http://www.example.com/ru/blog/

http://www.example.com/jp/blog/

Note that the first installation cannot be under /en/ or just /

EDIT: See solution in my self-accepted answer below.

3
  • Yes, that is possible. It can be sub domain also. like blog.example.com – The WP Intermediate Jan 18 '18 at 9:49
  • Thanks, can you point me to any reference? I believe WordPress may only allow me natively to set up the multisite with /en/blog/ /en/blog/site2/ /en/blog/site3/. However, what I need is to be able to set up is multisite with different directories above the installation location, in this case swapping out en. – Joseph Shih Jan 18 '18 at 9:59
  • Thanks for your help. See my solution: wordpress.stackexchange.com/a/291790/135100 – Joseph Shih Jan 22 '18 at 9:36
1

Yes, your requirements are possible.

As addition, you can also use different domains for each language, like

  • http://www.example.cn/blog/
  • http://www.example.ru/blog/
  • http://www.example.jp/blog/

if you need also relationsships betweent the posts of different sites, in your context languages, you can realize this via custom code or an existing plugin, like Multilingual Press.


8
  • I believe WordPress may only allow me natively to set up the multisite with /en/blog/ /en/blog/site2/ /en/blog/site3/. However, what I need is to be able to set up is multisite with different directories above the installation location, in this case swapping out en. – Joseph Shih Jan 18 '18 at 10:02
  • 1
    Your main installation should be without en, so that all languages are a directory after domain, like example.com for the main and en, jp as directory, NOT sub-domain. It is also possible to remove the blog, is only a change after installation in the settings of the Multisite and his permalink rules. You should also find good answers here on WPSE. – bueltge Jan 18 '18 at 10:05
  • Yes, the blogcan you remove after the install. see wordpress.stackexchange.com/a/107903/170 – bueltge Jan 18 '18 at 11:24
  • I'm sorry, but I don't think you understand. What I mean is that my original installation MUST be installed inside example.com/en/blog/. This we cannot change. We must install this there. Then enable multisite and have the new site "ru" use the path example.com/ru/blog/. – Joseph Shih Jan 18 '18 at 12:45
  • But you can also use a Sub site as main site, so that you rewrite the example.com to example.com/en/blog I use this often for Admin Dashboard with lot of information etc. not for users, front- and back end. – bueltge Jan 19 '18 at 13:52
0

I got it working! The trick was writing a variable PATH_CURRENT_SITE definition after enabling and altering the additional site settings. Simple, and no other special htaccess rewrites or code needed.

Step 1) Original installation

Under https://www.example.com/en/blog/

Step 2) Enable multisite

https://codex.wordpress.org/Create_A_Network

Step 3) Add new sites

In the network admin, start with just adding each additional site under another subdirectory such as ru in https://www.example.com/en/blog/ru/. Then, edit the URL after creating it to https://www.example.com/ru/blog/. Repeat this step for more sites.

Step 4) Edit wp-config.php file to define PATH_CURRENT_SITE dynamically

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.example.com');
// Previously just: define('PATH_CURRENT_SITE', '/en/blog/');
preg_match('/^(\/[a-zA-Z]+\/blog\/)/', $_SERVER['REQUEST_URI'], $matches);
if (!is_array($matches) || !isset($matches[1]) || !is_string($matches[1]))
{
    die('INVALID DIRECTORY');
}
define('PATH_CURRENT_SITE', $matches[1]);
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

STEP 5) Cleanup permalink

To prevent double blog slugs like /en/blog/blog/post-name/, go to the site settings (in the network admin) and edit the permalink settings.

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.