# Wp multisite primary site accessible using /wp

**URL:** https://discourse.roots.io/t/wp-multisite-primary-site-accessible-using-wp/5312
**Category:** trellis
**Created:** 2015-11-19T12:26:16Z
**Posts:** 15

## Post 1 by @cclass — 2015-11-19T12:26:17Z

Hi,

Just got Trellis + Bedrock up and running with WP Multisite and I’ve noticed that the primary site (e.g. [website.com](http://website.com)) is accessible via [website.com/wp](http://website.com/wp) and [website.com](http://website.com) (so, for example, i can get to the admin dashboard at either [website.com/wp-admin](http://website.com/wp-admin) or [website.com/wp/wp-admin](http://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](http://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!

Chris

---

## Post 2 by @rhud — 2016-01-25T12:19:30Z

hi @cclass,

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

Cheers

---

## Post 3 by @ben — 2016-01-25T15:41:35Z

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

> <https://github.com/roots/trellis/blob/11516d12e42355d0304eb4fb8c15be7ca8fcf6d4/group_vars/development/wordpress_sites.yml#L23-L24>

What are yours set to?

---

## Post 4 by @cclass — 2016-01-25T16:01:23Z

@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?

Cheers

Chris

---

## Post 5 by @ben — 2016-01-25T16:04:57Z

> [@cclass](#):
>
> Surely it’s something to do with nginx rewrite rules?

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

> <https://github.com/roots/trellis/blob/11516d12e42355d0304eb4fb8c15be7ca8fcf6d4/roles/wordpress-setup/templates/wordpress-site.conf.j2#L24-L31>

---

## Post 6 by @cclass — 2016-01-25T16:19:07Z

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 %}
```

---

## Post 7 by @ben — 2016-01-25T16:50:32Z

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

---

## Post 8 by @cclass — 2016-02-09T15:29:32Z

sorry for the delayed reply

on the primary site, `siteurl` and `home` are set to [http://website.local/wp](http://website.local/wp)

on each of the subdomain sites, `siteurl` and `home` are set to [http://subdomain.website.local](http://subdomain.website.local)

Cheers

---

## Post 9 by @rhud — 2016-02-18T05:24:11Z

@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](http://swift.dev/wp)

 ![](https://discourse.roots.io/uploads/default/original/2X/c/c3d99040f32a7feeac4048611616c141fd804ec7.png)

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

Any further thoughts?

---

## Post 10 by @cclass — 2016-02-18T12:52:27Z

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

---

## Post 11 by @JSDieNeu — 2016-02-24T14:54:20Z

Any news on that? I have the same issue…

---

## Post 12 by @JSDieNeu — 2016-02-24T15:27:53Z

Ok, my workaround:

Changing the home option in database

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

---

## Post 13 by @darjanpanic — 2016-06-15T19:50:03Z

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.

---

## Post 14 by @cfx — 2016-07-13T02:24:53Z

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

There’s also [this Bedrock PR](https://github.com/roots/bedrock/pull/251) which appears to do a good job of fixing the main site URLs and maintaining the admin URL structure.

---

## Post 15 by @mikelittle — 2016-09-09T18:05:45Z

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.
