4

I have following situation. I have a WP Multisite installed in subdirectory:

my-domain.com/subfolder/wp-multisite-root

Now normally next sites added would be created like that

my-domain.com/subfolder/wp-multisite-root
my-domain.com/subfolder/wp-multisite-root/site1
my-domain.com/subfolder/wp-multisite-root/site2
my-domain.com/subfolder/wp-multisite-root/site3

Is there any way to have it created like this?

my-domain.com/subfolder/wp-multisite-root
my-domain.com/subfolder/site1
my-domain.com/subfolder/site2
my-domain.com/subfolder/site3

There is one more trick. my-domain.com/subfolder/ contains another non wordpress application.

  • What non wp application means? What .htaccess / slug conflicts do you have? – brasofilo Oct 20 '13 at 20:26
6

After these years I hope this will still answer your question...

I think I've got the situation working you want. Allthough I don't have the Wordpress installation in '/subfolder/', but I've a installation 'in subdirectory' per language, and on the same level:

 my-domain.com/nl/ -> this is primary installation, site id = 1 
 my-domain.com/en/ -> this is the first site created by multistie, site id = 2
 my-domain.com/de/ -> this is the second site created by multistie, site id = 3

It requires a bit 'hacking' in the database, but it's very easy.

Step 1: Make sure your multisite 'root' installation is working as intended in it's subdirectory. In my case I got the following in 'wp-config.php':

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false); // allow sub-directory install (true for subdomain install)
define('DOMAIN_CURRENT_SITE', 'my-domain.com/subfolder');
define('PATH_CURRENT_SITE', '/wp-multisite-root/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

(well in reality I don't have '/subfolder' :) )

Step 2: Now create you're first new site through multisite in a subfolder. When entering the foldername 'site2', Wordpress tells you it will be created as: my-domain.com/subfolder/wp-multisite-root/site2 That's correct, we will remove the 'wp-multisite-root' folder manually t

Step 3: Open up phpMyAdmin/directAdmin In the table wp_blogs edit the entry of you're newly created site. We will have to modify the path of it. It can be done with the following query:

UPDATE `wp_blogs` SET `path` = '/site2/' WHERE `wp_blogs`.`path` = '/wp-multisite-root/site2/';

Change domain name and site name accordingly. Also look for the site id mentioned there. If its the first extra site created it will be ID 2 as in my intro.

Step 4: Look into the table wp_<SITEID>_options. In our case with Site ID 2, it will be wp_2_options. There we will have to change the option_value where the option_name is 'siteurl' and 'home'. It can be done by running following queries:

UPDATE `wp_2_options` SET `option_value` = 'my-domain.com/subfolder/site2/' WHERE `option_name` = 'siteurl';
UPDATE `wp_2_options` SET `option_value` = 'my-domain.com/subfolder/site2/' WHERE `option_name` = 'home';

Again, change the domain and folder name accordingly. You'll note that we remove 'wp-multisite-root' from the url there, so site2 will be on the same level as `wp-multisite-root'.

Step 5: Refresh wp-admin and your site(s) will be listed as you wanted.

4

Piemol's answer is great and worked for me. However, I was unable to log into any of my sites except the main site. Upon inspecting my cookies, I discovered WordPress was making a cookie for only my main site and not the other subdirectories. To use OP's example, it was making a cookie for /subfolder/wp-multisite-root, which /subfolder/site1 could not use.

I dug through WordPress core to see what I needed to fix, and I ended up adding this code to my custom plugin to fix the paths used for the cookies:

define('COOKIEPATH', '/subfolder/');
define('SITECOOKIEPATH', '/subfolder/');

In my case, my site structure is actually like Piemol's, so I fixed my cookie paths to be the root:

define('COOKIEPATH', '/');
define('SITECOOKIEPATH', '/');
1

The simplest solution is to make my-domain/subfolder/ the WordPress install directory and base URL, then enable multisite configured to use subdirectories.

  • Sorry forgot to add my-domain/subfolder/ contains an application. – HoGo Oct 20 '13 at 18:05
  • Maybe move the application? – Chip Bennett Oct 20 '13 at 18:10
  • @ChipBennett would that override any of the current site configurations? – Rahman Sharif Jun 15 '14 at 12:15
  • How to make install directory into subfolder? – John_J Jan 1 '19 at 12:12
-1

I've been trying to do a similar thing, and from everything I've discovered so far I think the answer is no, this isn't currently possible :(

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.