I am on a VPS running Nginx as a backend server.
I want to set up a sub-directory multisite WordPress installation, however I want all sub-sites to be under one sub-domain also. For example:
My main site:
domain.com
Subsites:
clients.domain.com/site1
clients.domain.com/site2
clients.domain.com/site3
I realise I can install another copy of WordPress under clients.domain.com
and use that as the Multisite home, however since domain.com
is already running WordPress this strikes me as inefficient in terms of management and disk space especially as I only wish to serve a login page at the root of that subdomain anyway.
I also realise I can redirect all requests to clients.domain.com
to domain.com
however I don’t want the subsites or their related files to be accessible via domain.com/site1
. The subsites should recognise their parent site as being domain.com
.
What is the best method for going about this?
This has been solved, please note I am using WordPress 3.8 at the time of writing this, if you are from the future these plugins may not work with your current version, please check compatibility first.
The plugin WP Multi Network provides this functionality. It basically allows you to create nested multi-site networks. I have my primary network at
domain.com
and created another network calledClients
atclients.domain.com
.Now
domain.com
points to my main site, but any subsite I create from theClients
network will take an URL in the formatclients.domain.com/sitename/
. All networks share the same database.I used the standard wordpress subdirectory multisite configuration for Nginx (http://codex.wordpress.org/Nginx) and use the plugin Nginx helper to generate my
map{}
rules.I hope this helps anyone else who has this issue. You can now create multiple multisite networks at different subdomains (or different domains) sharing a single database and administration panel.
You can use a drop-in called
sunrise.php
to change the way, WordPress maps the request on a blog in your network. I explained a possible solution in this answer. The key is to parse your requestclients.domain.com/site1/some/post/
into the domainclients.domain.com
and path/site1
and compare it with the columnsdomain
andpath
in thewp_blogs
table. On this way, it’s up to you how to handle Subdomain and Paths as identifier for blogs. With this data you have to set up some global variables like$current_blog
and$current_site
.When you use a sub domain install, you necessarily need not to change the admin GUI. Just create a blog with the domain
clients.domain.com
after that, go to the edit screen of the blog and alter the path. It’s not very comfortable but it works.It’s of cause possible, that you ran into path conflicts when using different path levels as root paths for blogs. Because
sunrise.php
is called very early, the blog path will allways win over the permalink path.Here is one very simple solution: