# Local development with Multisite

> Pull a WordPress network to your computer with DDEV. Subdirectory networks open at / and /es/, subdomain networks get a local name, and your prefix is kept.

Source: https://docs.wpwaterfall.com/local-development-with-multisite

The WP Waterfall add-on for DDEV works with a WordPress Multisite network and with any table prefix. Set it up as in [Develop locally with DDEV](https://docs.wpwaterfall.com/develop-locally-with-ddev): download the starter and run its setup script, or run `ddev wpwaterfall setup SITE`. This article covers what changes for a network. Every address on this page is https, with no port number when DDEV can use port 443. On Windows, see [Local development on Windows with WSL2](https://docs.wpwaterfall.com/local-development-windows-wsl2).

## Your table prefix

The add-on keeps the real table prefix of the environment and never assumes `wp_`. Search and replace runs on every table that starts with it. See [Database table prefix](https://docs.wpwaterfall.com/table-prefix).

## A subdirectory network

A network where the English site is at `/` and the Spanish site is at `/es/` opens the same way on your computer:

- `https://your-project.ddev.site/` is the main site.
- `https://your-project.ddev.site/es/` is the Spanish site.
- `https://your-project.ddev.site/es/wp-admin/` is its dashboard.
- Uploads of the Spanish site are in `wp-content/uploads/sites/2/`.

The add-on rewrites the network address, every site, and the settings in `wp-config.php` to your local address. It also adds the web server rules a subdirectory network needs.

## A subdomain network

DDEV can serve every name under your project address. The add-on turns on a wildcard name for your project, and DDEV makes the certificate. A site that ran at `es.example.com` opens at `https://es.your-project.ddev.site/`.

This needs the `ddev.site` names to resolve to your computer, and the browser to trust the certificate. `ddev wpwaterfall doctor` checks both (`dns` and `https` lines). The one wildcard certificate covers every subsite, so `ddev wpwaterfall trust` is needed once. If `es.your-project.ddev.site` does not resolve, your router or DNS server is blocking names that point at your own computer: use a DNS server such as `1.1.1.1`, or add each name to the hosts file.

## The address map

The add-on writes `.ddev/wpwaterfall-network.json`. It lists each site with its WP Waterfall address and its local address. It holds no secret. Every database pull rebuilds it from what WP Waterfall reports. Do not edit it. An [update](https://docs.wpwaterfall.com/develop-locally-with-ddev#keep-the-add-on-up-to-date) never rewrites the map: when the network gains a site, the update says to run `ddev wpwaterfall pull --db`, and the database pull rebuilds it.

## Push to staging

You can push your local database to **staging** or a **preview**, never to live. For a network the add-on first turns every local address back into the address of that environment, one site at a time. It does this on a copy, so your local database stays as it is.

The push stops, with a plain message and before anything is uploaded, when the map is not safe to reverse:

- the map is missing or older than the network (a site exists in only one place);
- two sites would get the same address;
- you created a new site on your computer, because WP Waterfall cannot know where it belongs. Create it in the Network Admin of the environment, then pull again.

## Check your setup

Run `ddev wpwaterfall doctor`. It shows the prefix, the network type, the state of the map, and the local names. If you use custom ports (the last resort when ports 80 and 443 are taken), every subsite address carries the port, and a pull writes it into each subsite.

## Limits

- A subdomain network on a computer without working `ddev.site` name resolution needs a hosts file change.
- Posts created on your computer keep the local address in their `guid` after a push.
- Pushing a new local site to a network is not supported.

## Related

- [Develop locally with DDEV](https://docs.wpwaterfall.com/develop-locally-with-ddev)
- [Pull a database and files](https://docs.wpwaterfall.com/pull-a-database-and-files)
- [WordPress Multisite](https://docs.wpwaterfall.com/wordpress-multisite)
- [Database table prefix](https://docs.wpwaterfall.com/table-prefix)
- [Local development troubleshooting](https://docs.wpwaterfall.com/local-development-troubleshooting)
