When migrating some WordPress blogs on a multisite install to a new host running Ubuntu, I found all the images were broken in every blog except the first one.
Eventually I found the culprit: the /usr/share/wordpress/.htaccess
file was being ignored, which meant the Apache httpd RewriteRule of requests for files/ was not being redirected to the correct blogs.dir/… files (and let’s not dwell on how inefficient it is serving large files via ms-files.php, which is apparently only used for multisite blogs created before WordPress 3.5):
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
To fix this problem, I enabled .htaccess for /usr/share/wordpress
by creating /etc/apache2/conf-available/wordpress.conf
with the following contents:
# Allow .htaccess in WordPress directory
# Without this to enable .htaccess, images/files in multisite WordPress installs would be broken due to missing rewrite rule
<Directory /usr/share/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Then I enabled it with a2enconf wordpress.conf
and systemctl reload apache2
.
Hope this helps someone save some time!