OK, check this out, broken resources:
Lets check out one of these resources:
Huh? Why is the resource at http://schnell-engineering.com/?ver=4.4.16
? Didn’t we want wp-embed.min.js
? Lets check the requests…
That doesn’t look good. Bunch of 301s. These redirects are coming from Apache, too. And they’re telling us to go get http://schnell-engineering.com/?ver=4.4.16
for some reason…
OK, so we’re getting redirected away from all of our static resources, and being given a HTML document for every request instead! Not what we want at all. Why is that? To explain, lets analyse the rewrite
you’re using:
What’s the rewrite
doing? If the conditions match, it checks whether {path}
exists on disk in the webroot. What’s the webroot? Well, it wasn’t set explicitly, so it’ll be the working directory of the Caddy process on the Caddy host. This rewrite expects WordPress files to be there. What does it do if it can’t find them?
It changes every single request to read http://schnell-engineering.com/index.php?{query}
, because that’s the last rewrite target. Then, rewrite done, proxy
sends that request upstream!
What does Apache do with that? Well, firstly, /index.php?ver=4.4.16
is the wrong way to request an index. Apache wants to tell you that you can just request /?ver=4.4.16
. We’ve just explained our Status 301 response with the Location: http://schnell-engineering.com/?ver=4.4.16
header.
What happens next, once the browser goes to the new location for the resource? It gets an index file, of course. HTML - when it was expecting JavaScript. And now we’ve explained the console errors and the lack of any site resources or styling.
How do we fix it? TL;DR: Just remove the rewrite
from your Caddyfile entirely. You don’t need it - Apache handles that routing already. When I posted the example above, that was the whole Caddyfile.