5

We have a WP network (with domain mapping) that was started pre WP 3.5, so it was using ms-files.php and wp-content/blogs.dir/ to store media files. I wanted to remove ms-files.php dependency and after doing some research started the process:

I first tried not moving any files from blogs.dir/#/files to uploads/sites/#, but to setup symlinks for that. Then I had some permissions issues so I just copied everything from blogs.dir/#/files to uploads/sites/#.

Then I cleared the values for upload_path, upload_url_path and fileupload_url on each site.

And finally updated/inserted ms_files_rewriting = 0 in the wp_sitemeta table.

Also added some rewrite rules to the .htaccess file to not have to deal with updating all URLs in DB.

The main blog id in our setup is 2 and not the default which is 1: define('BLOG_ID_CURRENT_SITE', 2);

As far as I know, and based on what I see in wp_upload_dir(), WP uses the root of the uploads folder for the main blog contents and uploads/sites/# for other blogs. So I have copied the content from blogs.dir/2/files to the root of the uploads folder and NOT to uploads/sites/2.

Now here is the issue for media files on the MAIN BLOG: in the back-end, WP loads files from the uploads folder which is fine, but on the front-end it tries to load files from uploads/sites/2 which doesn't exist and is weird!

PS: I can just add another rewrite rule to have this fixed, but I really want to know what the reason is for /sites/2 being added for the main blog.

1
  • 1
    I've arrived at the same sort of problem via a different path. After migrating to a new hosting provider (and making a few tweaks along the way) I'm also seeing the back-end work fine but the front-end using the the blogs.dir directory for the main site. Did you find a solution? – KenB Jan 28 '15 at 15:36
1

WordPress multisite's "Upload Path" should be set to a server-relative path (e.g. /home/serveraccountname/public_html/wp-content/uploads).

The "Upload URL Path" should be the URI (e.g. http://example.com/wp-content/uploads).

Ignore the /sites/1/ fragment for sub-sites - WordPress will add these automatically.

0

We used to be able to set the directory where files were kept and that option was removed so this might have something to do with the misdirected links. I had the same problem, but I went through and reuploaded the files that weren't working properly. This might not be realistic if you have lots of files but it is one option. Another option is to use a plugin like Broken Link Checker by Janis Elsts. It will search your site for links that don't work and it gives you the option to easily change the URLs. It will also send you an email and tell you if any other site connected to a link stops working. It is very useful and I use it on most of my websites now. ^^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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