This WordPress plugin makes it possible to nest sites under other sites in a WordPress network with subdirectory sites.
For example, by using this plugin, all of the following can be valid
WordPress sites in the example.com
WordPress network.
- mysite.com
- mysite.com/first
- mysite.com/first/second/
- mysite.com/first/second/third
- mysite.com/fourth
You must have installed WordPress and created a network.
-
Move the
wp-nester
folder intomu-plugins
. -
Move
sunrise.php
into the root of yourwp-content
folder. Ifsunrise.php
is already present there, then merge in the contents. -
Edit
wp-config.php
and uncomment or add theSUNRISE
definition line. If it does not exist, paste the following on the line above the lastrequire_once
command.define( 'SUNRISE', 'on' );
-
Update your the
.htaccess
file in the root of your WordPress installation to contain the following.# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wordpress/ 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] </IfModule> # END WordPress
Unfortunately, there is a snag when creating sites. We are looking for ways around it, but it's impossible without editing the WordPress core. So you have two options:
-
Apply the the diff file
site-new.diff
. If you view source you'll see that we only need to add one character, but it's crucial. You could use something like this command in your WordPress install folder.patch -p1 </path/to/wp-nester/site-new.diff
OR
-
Create sites first with an un-nested URL such as
example-site
, and then edit them afterwards to be nested, likesubsite/example-site
. This avoids the error that you'll receive if you attempt to create a site with a nested URL initially.
Currently only tested with WordPress 3.6 and 3.8.1.
Our work is based heavily on the code represented in the following post and comments.