Migrating access for subdirectory-based wordpress sites to Netlify

Hi @twilightscapes! It is indeed possible to redirect subdomains (or full domains) to subdirectories. In fact, that’s exactly what’s happening in the examples I posted in the comment you linked in this topic. For your multisite setup, you’d probably still want to have each frontend site as a separate site on Netlify, and the redirect would just add one more directory level to the target path.

For example, for a site at client1.com, you can set a redirect rule like this:

/doorbell    https://mywpserver.com/client1/wp-admin   200

Then, when someone visits client1.com/doorbell, they see their admin UI at mywpserver.com/client1/wp-admin. The 200 code at the end of the rule sets the redirect as a rewrite, which means browser URL bar still shows the client1.com address, even though the browser is accessing mywpserver.com/client1.

That covers admin access on the WP server, but you also mentioned using the server as the data source for the frontend sites, presumably using the WP API. There are two ways to do this.

In many cases, it’s preferable to access the WP data at site build time, so the data can be baked in to pre-built html pages. In that case, you would set up your site generator or build tool to access the API endpoints at whatever URL they need — no redirects needed. In a multisite setup, that would involve GET requests to a URL like https://mywpserver.com/client1/wp-json/some-endpoint.

On the other hand, if you’re accessing data (like comments, say, or related posts) directly from the client with JavaScript, you could again access the API endpoints directly, but you’d have to deal with CORS, and you’d expose your server address in client-side calls. To avoid both of these problems, you can add a proxy rewrite rule.

Using the client1.com site example again, you could have a rule like:

/api/*    https://mywpserver.com/client1/wp-json/:splat  200

With that, you can code your JS GET requests to point to relative links like /api/this-endpoint and they’ll reliably and invisibly go to https://mywpserver.com/client1/wp-json/this-endpoint.

Hope that helps!