Install WP multisite in a subfolder and create new sites at the same level as the main install.

We were looking for a fix for around 2 weeks and stumbled across the below. For anyone wanting to move have some other cms installed in the route folder. And then have WordPress multisite installed in a subdirectory/subfolder, who wants to then create new WordPress subsites at the same level as the main multisite which is located in a subfolder.

Create your multisite.

12/* Multisite */define('WP_ALLOW_MULTISITE', true);

Assuming you know how to do that let’s move on.

Firstly, have your multisite setup in a subdirectory:

  • www.mydomain.com/blog/
  • www.mydomain.com/blog/site1
  • www.mydomain.com/blog/site2

Second, add a directory in the root, this should be the same as the first and second site you just created:

  • www.mydomain.com/site1

In that newly created directory (/site1/), you can add a .htaccess to rewrite all requests to the multisite installation. This code worked for us in the .htaccess file:

RewriteEngine On RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(index\.php)$ /site1/$1   

RewriteRule ^(.*)$ /site1g/$1

Now everything should be working, and when you visit www.mydomain.com/blog you should see your multisite subsite. The only problem is that sometimes you cannot log in because of some cookie domain conflicts. To fix this, delete all the domain cookies (use chrome dev tools). Secondly, add these lines to the wp-config.php file:

define('ADMIN_COOKIE_PATH', '/'); 

define('COOKIE_DOMAIN', '');

define('COOKIEPATH', ''); 

define('SITECOOKIEPATH', '');

Hopefully it works for you.

 

Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!