Can WordPress and WordPress Multisite share the same domain?

Using Trellis, I would like to have a separated marketing website (WordPress) and an application (WordPress MultiSite) which share the same domain.

The marketing website would be located at: and (redirects to root)

The application website would be located at:

That’s easy enough on its own, but an issue arrises when additional blogs are added to the WordPress Multisite. They all use the primary site’s sub domain This is expected, but I would like to change it…



Is this in any way possible?

Here are some thoughts to get you started. I didn’t test. This may not work.

The details below describe three steps:

  • edit three Trellis vars:
    • wp_home
    • wp_siteurl
    • multisite_subdomains_wildcards
  • edit COOKIE_DOMAIN in Bedrock’s config/application.json
  • change one URL setting in the WP admin


  # marketing site
      - canonical:
      enabled: false
  # app / blogs  # <-- site key must differ from site key above if on same server
      - canonical:
      enabled: true
      subdomains: true

Regarding, I’m guessing the wp_home value of (no app subdomain) will mean that WordPress will default to creating new subdomain blogs at etc. (I’m not certain).

Domain mapping for

However, the wp_home above will probably mean that WordPress will interpret the primary site as being at I think you could set up domain mapping to change the URL to for this site:

Go to Network Admin -> Sites -> Edit Site -> edit the site URL
(see toscho and discourse thread)

For WP admin logins to work, edit your Bedrock config/application.json:

- define('COOKIE_DOMAIN', '.' . env('DOMAIN_CURRENT_SITE'));
+ define('COOKIE_DOMAIN', '');

:warning: I don’t know if there are negative consequences of this COOKIE_DOMAIN change. I identified this change as necessary to avoid a login redirect loop like this and I didn’t look further.

Nginx conf server_name

The wordpress_sites above would normally create the following for Nginx server_name:

server_name *;

We need to find a way to make this change:

- server_name *
+ server_name *

I normally wouldn’t encourage anyone to edit a helper variable like multisite_subdomains_wildcards, but it may be simpler than working out a child template.

- multisite_subdomains_wildcards: "{{ item.value.multisite.subdomains | default(false) | ternary( site_hosts_canonical | map('regex_replace', '^(www\\.)?(.*)$', '*.\\2') | list, [] ) }}"
+ multisite_subdomains_wildcards: "{{ item.value.multisite.subdomains | default(false) | ternary( site_hosts_canonical | map('regex_replace', '^(app\\.)?(.*)$', '*.\\2') | list, [] ) }}"

The relevant portion of the diff above is toward the end of the line:

- ...('regex_replace', '^(www\\.)...
+ ...('regex_replace', '^(app\\.)...

Normally multisite_subdomains_wildcards just ignores a www portion, e.g., it would make: *

In your case we’d like to ingore the app portion (from canonical way above in wordpress_sites, yielding: *


It looks like you intend to use https. Until Let’s Encrypt starts offering wildcard certs in January 2018, you’ll need to obtain a wildcard cert elsewhere (unless you know the exact blog subdomains and want to list them in site_hosts of wordpress_sites). I’m guessing you are already familiar with the related discourse threads on the topic.

1 Like