Everything works so far with the current website. All admin pages work. All front end pages work with pretty urls. So .htaccess is doing its thing.

Now when I add a new site, I visit its admin dashboard area and this is where things go wrong. Any url that is of this pattern http://website.com/[site-name]/wp-admin/[page].php returns a 404 error usually with the message “file not found”.

This is strange because WordPress usually knows what to do at this point based off of the htaccess file.

So if the file does not exist then the rule after is checked and ran if it matches

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

So for example: this url http://website.com/my-site/wp-admin/settings.php Should rewrite to this http://website.com/wp-admin/settings.php where the file does exist. But, it appears that this is not happening despite the rewrite rules working for everything else WordPress related. It just appears to fail and not really give a damn about anything else.

One thing to note is I did update to Sierra somewhat recently but I can’t confirm this setup working before the update.

Update

I added Rewrite logs to the error logs. When I visit a url that is a folder like so: http://website.com/does/not/exist I get a log history of all the patterns mod_rewrite tests and that shows there was a rewrite to the index.php file where WordPress serves the 404 error. So this is working as expected.

When I again go to this url http://website.com/new-site/wp-admin/settings.php I get the 404 error with ‘file not found’ on the page BUT…..its not logged. So I assume that Apache is returning the 404 error before it reaches the htaccess with all the mod_rewrite stuff.

Important Note
I want to reiterate that htaccess is working. The only scenario where apache serves the 404 error before it reaches the htaccess file is when I use a url that has a file extension. So I feel like apache is using something else first to handle that 404 well in advance before the htaccess gets a chance to rewrite anything. Hence why the logs work in any other scenario but not for urls like http://website.com/my-site/wp-admin/settings.php.

I have checked the http.conf file but nothing seems obvious as to what could be handling the file not found stuff.

UPDATE 2018-02-11

Ok so I think I am on to something. This probably has something to do with the ProxyPassMatch condition I have setup in my virtual host config. Here is what the contents of that file look like:

Now I have been using the curl command to make a request to keep the log output simple. I would test the load-scripts.php file from the main website at http://wp-test.test/wp-admin/load-scripts.php which works as expected and then I would test the failed one at http://wp-test.test/testing/wp-admin/load-scripts.php.

testing in this example is the name of the subsite. Now here is the logs of each:

So it appears that everytime ProxyPassMatch tries to match to a file that doesn’t exist I get the ‘file not found’ error. Its trying to map to this location: /Users/joemoe-mac/Sites/wp-test.test/public/testing/wp-admin/load-scripts.php when the file is located here /Users/joemoe-mac/Sites/wp-test.test/public/wp-admin/load-scripts.php without the testing folder (because subsites share the same files as the main site)

I guess my next question is how do I setup a proxy properly with a WordPress Subdirectory multisite?