WordPress multi-site sub domain help


#1

I want to set up an instance of WordPress multi-site. The question I have is regarding sub domains.

I wish to set it up so that I can have site1.domain.com, site2.domain.com and so on. The problem is that I don’t own domain.com the sub domains are created at my request. I’m assuming for this reason that I cannot use wildcard subdomains, as https://codex.wordpress.org/Tools_Network_Screen states is required.

Would it be possible to set up WordPress so that it uses sub-directories and then forwards the sub-domain and mask the actual url. So, for example, the user would type site1.domain.com Symbosis would then forward the user to domain.com/site1, however, the url would appear to the user to be site1.domain.com?


#2

Hi Dave,

Looking at the docs you linked, it’s more focused to normal web-hosting where you don’t have access to change the config and what hostnames point where.

In Symbiosis it’s fairly simple, and can be done either by adding a symlink from the new subdomain to the existing domain where WordPress is set up, or if you want to have separate SSL certs and mail/etc configurations, you can symlink the htdocs/ directory.

Heres a couple of examples, using example.com as the main site, and subdomain.example.com as the new subdomain.

Merged email/SSL/configuration:

Create a symlink for the new name, pointing to the existing name.

$ ln -s /srv/example.com /srv/subdomain.example.com

This will alias both the web and other traffic, so mail sent to user@example.com will be the same as user@subdomain.example.com (and any other subdomains), and the automatic SSL certificate will have subdomain.example.com added to it after a while.

Seperated email/SSL/configuration:
Create the directory (move/remove the automatically created htdocs in Symbiosis Stretch) and link the new htdocs/ directory to the existing setup, so they share the same files.

$ mkdir -p /srv/subdomain.example.com/public
# The line below is needed in Symbiosis Stretch as the htdocs directory is automatically populated - if you're using Symbiosis Jessie, you can skip it.
$ if [ -d /srv/subdomain.example.com/public/htdocs ]; then mv /srv/subdomain.example.com/public/htdocs /srv/subdomain.example.com/public/htdocs_old; fi
$ ln -s /srv/example.com/public/htdocs /srv/subdomain.example.com/public/htdocs 

This will set up what is in effect a separate configuration as far as Symbiosis is concerned, with it’s own SSL certificate, mail configuration and so on.

Hopefully the above all makes sense, but if you have any other questions just drop a reply here!


#3

That great, just one question if you could clarify please?

I don’t own or have access to example.com and can only request that a new sub domain be created. I assume in your example /srv/example.com/ is where WordPress is installed? Does it matter what the folder /srv/example.com is called? Could it be something like /srv/dave.com/ ?


#4

How would WordPress be set up, using the sub domain setting, or sub folders? Once the symlink had been created how would WordPress know that this was a different site? I presume I would need to create one in WordPress itself?


#5

I think there is a lot of confusion here. Maybe read this resource as I think this is what you are asking about https://www.wpbeginner.com/glossary/multisite/