Wp multisite primary site accessible using /wp


Just got Trellis + Bedrock up and running with WP Multisite and I’ve noticed that the primary site (e.g. website.com) is accessible via website.com/wp and website.com (so, for example, i can get to the admin dashboard at either website.com/wp-admin or website.com/wp/wp-admin).

Perhaps I’ve overlooked a step during setup, but shouldn’t there be redirects in place?

Adding a new subdomain site works fine and doesn’t have the same problem (e.g. sub.website.com/wp just 404s)

Another thing I should note is that I wasn’t able to go through the Network Setup for WP Multisite as that screen provides .htaccess rules and Trellis uses nginx (I’m not sure how to configure rewrite rules for nginx).

Or am I wrong in thinking that the site shouldn’t be accessible via both URLs?

Thanks in advance for any help!


hi @cclass,

I’m having the same issue - did you get this sorted?


Sounds like a mis-configuration of your home/siteurl environment values

What are yours set to?

@rhud I haven’t figured this out yet – tbh I moved on after spending to much time on it but I’d still like to get it resolved at some point.

@ben my configuration matches what’s in the docs except I don’t use ‘example.dev’ which I assume doesn’t matter. Just in case, I switched back to ‘example.dev’ but that doesn’t resolve the problem. Surely it’s something to do with nginx rewrite rules?



Possibly! Do your rules reflect what’s in the current Trellis codebase?

yes, they do. i do have multsite subdomains enabled.

{% if item.value.multisite.enabled | default(false) -%}
    {% if item.value.multisite.subdomains | default(false) -%}
      rewrite ^/(wp-.*.php)$ /wp/$1 last;
      rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
    {%- else -%}
      include wordpress_multisite_subdirectories.conf;
    {%- endif %}
  {%- endif %}

If you look at the options table in the database, what are you seeing as the values for the home and siteurl?

sorry for the delayed reply

on the primary site, siteurl and home are set to http://website.local/wp

on each of the subdomain sites, siteurl and home are set to http://subdomain.website.local


@cclass @ben my configuration is also the same:

wp_home: http://swift.dev
wp_siteurl: http://swift.dev/wp

and my nginx rewrites are the same.

However, in wp admin it has both Home &Siteurl as http://swift.dev/wp

My second site doesn’t add the /wp - just the primary site.

Any further thoughts?

yep, that’s exactly what i’ve got. same issue with a fresh new trellis/bedrock project.

Any news on that? I have the same issue…

Ok, my workaround:

Changing the home option in database

UPDATE wp_options SET option_value='http://mysite.dev' WHERE option_name='home';

1 Like

i have this problem now as well, did anyone try to solve the problem without going to db and change it manually?

my solution was to use wp option update home http://example.dev on the vagrant box current/ directory.

It’s strange that both siteurl and home are set to /wp. It could be that since wp gets auto installed, the settings for home somehow switched to siteurl one. I couldn’t find a way to set home programatically so it may be on some stage be put to the DB and loaded from there.

I also noticed that wp/wp-admin is used by the main site dashboard, but the network admin is loading directly from /wp-admin.


Thanks @darjanpanic. I experienced this too, submitted a PR to include your fix: https://github.com/roots/trellis/pull/616

There’s also this Bedrock PR which appears to do a good job of fixing the main site URLs and maintaining the admin URL structure.

1 Like

You don’t need any code to handle the ‘wp’ part in any admin urls. Instead an nginx rule will do it for you.

Assuming that neither the ‘home’ nor ‘siteurl’ options have ‘/wp’ in them (and they shouldn’t): I have this additional rule on my Bedrock-based site config (server block) to fix everything.

#subdomain multi site with wp in 'wp' subdir
if (!-e $request_filename) {
    # Redirect wp-* files/folders
    rewrite ^(/[^/]+)?(/wp-.*) /wp/$2 last;

    # Redirect other php files
    rewrite ^(/[^/]+)?(/.*\.php) /wp/$2 last;

It fixes all the problems!

Note, I think there is a faster way to do it than using rewrites, I just haven’t figured it out yet. It probably can be done with try_files.