1

I've two wp sites (multisite) with the following config:

1#

(Main site) Home: http:// www.mysite.com

Upload Path: wp-content/uploads

Fileupload Url: http:// www.mysite.com/wp-content/uploads

2#

Home: http:// www.mysite.com/en/

Upload Path: wp-content/blogs.dir/2/files

Fileupload Url: http:// www.mysite.com/en/files

My .htaccess has the following:

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

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

The first site is working 100%, i can upload images, view them on the media library & post edit and they show OK in the page

The second site, when I upload the image, it shows a broken image: https://i.sstatic.net/EsMg4.gif

But when I click the "edit image" button it shows OK: https://i.sstatic.net/5gMIH.gif

I've checked and the image is on the right folder (http: //www.mysite.com/blogs.dir/2/files/honey.jpg) but it's broken in the admin panel and the site. The url of the broken image is: http: //www.mysite.com/en/files/honey.jpg

I've lost hours trying to fix it through .htaccess and changing the wordpress config but nothing seems to work. Any ideas?

Thanks!

1 Answer 1

2

After reading several topics about this issue I've found this:

Issues with old WPMU installs

If you installed WordPress MU in subfolder/subdirectory (not in root folder on your server >via ftp) and you have problem with image library, where thumbnails and images do not show, >you may need to manually add in rewrite rules for your file directories as follows:

RewriteRule ^([_0-9a-zA-Z-]+/)?siteN/files/(.+) wp-content/blogs.dir/N/files/$2 [L]

Put those below the normal call for uploaded files.

However, this didn't work, i had to replace (or comment) the uploaded files line and change the new one to work in all sites. In the end this is the .htaccess that worked OK:

# uploaded files
# RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-content/blogs.dir/N/files/$2 [L]

Being 'N' the number of my non-primary site

So, I guess that for each site, you have to add another line changing the number. Hope this helps.

3
  • Is blogs.dir supposed to replaced by the name of an actual directory or is that how you actually have it in your .htaccess file? Commented Aug 12, 2019 at 21:51
  • I had it like that. I just changed the N to match the website number. But this was back in 2012, I think wp multisite does not work like that anymore. Are you having the same issue? Maybe this can help: wordpress.org/support/topic/blogs-dir-in-wp-above-3-5 Commented Aug 14, 2019 at 9:46
  • Thanks. Turns out the issue was that the new server was running NGINX as a reverse proxy but still using Apache to serve the site so I had to edit the NGINX VHOST file. Commented Aug 14, 2019 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.