simple-cache icon indicating copy to clipboard operation
simple-cache copied to clipboard

Multisite + cache = broken images

Open oobi opened this issue 8 years ago • 2 comments

We've used this plugin on a few single instance wordpress installations and it has worked well. I've hit a bump trying to get it to work on a multisite instance. The site is setup as multisite "subdomains" (so xxx.domain.com, yyy.domain.com)

Something seems to be conflicting with the rewrite rule when caching is enabled.

With caching enabled, this file will be broken http://.../files/2012/10/Events.jpg

With caching disabled it's fine.

Here's the .htaccess for reference - nothing odd there I don't think.

# BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

</IfModule>
# END WordPress


#prevent direct php execution in wp-content folders
<IfModule mod_rewrite.c>
RewriteRule ^wp-content/.*\.(php|php3|php4|php5)$ - [R=404,L,NC]
</IfModule>

The error it throws is a 500 (server error) which would seem to indicate that wp-includes/ms-files.php is involved somehow, but there's nothing in the error log about it.

The oddest part is that this works fine in Firefox but not Chrome or Edge. I've cleared caches both locally and on the server to no avail.

Any thoughts?

oobi avatar Feb 20 '17 23:02 oobi

So a .jpg file is 500'ing? That sounds like a server issue.

tlovett1 avatar Feb 26 '17 07:02 tlovett1

It's not the jpeg per se - the jpeg itself looks fine, but paths like /files/something.jpg get piped through wp-includes/ms-files.php?file=something.jpg via URL rewrites on a multi-site configuration.

To use the example in my original post:

http://.../files/2012/10/Events.jpg

is rewritten as this:

http://.../ms-files.php?file=2012/10/Events.jpg <-- this is what fails

It only happens when Simple Cache is active though. Doesn't happen with WP Super Cache and other similar ones.

oobi avatar Feb 26 '17 10:02 oobi