I have a WordPress subdomain multisite install in the /blog subdirectory running on an nginx server. Everything works fine except files which do upload correctly but are not accessible via their url.

The part of the config concerning the files is:

location ~ ^/files/(.*)$ {
    try_files /blog/wp-content/blogs.dir/$blogid/$uri /blog/wp-includes/ms-files.php?file=$1 ;
    access_log off; log_not_found off; expires max;

#avoid php readfile()
location ^~ /blogs.dir {
    alias /var/www/example/public_html/blog/wp-content/blogs.dir;
    access_log off; log_not_found off;      expires max;


map $http_host $blogid {
    default       -999;

    example.com             1;
    a.example.com           2;
    b.example.com           3;
    c.example.com           4;

The WordPress sites have the following settings:

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

Upload Url Path: http://example.com/blog/files

Fileupload Url: http://example.com/blog/files

The number in the Upload Path is of course different for each site.

When I try to upload a file to any blogpost of any of the sites it does appear in the /blog/wp-content/blogs.dir/#/files/ folder but if I try to access /blog/wp-content/files/test.png it throws 404

Any ideas? Thanks!


1 Answer 1


I solved the problem by upgrading the way files are uploaded and displayed to the new WordPress 3.5 method.

A more detailed tutorial can be found at http://halfelf.org/2012/dumping-ms-files/ but the basic steps are as follows:

  • Move images from blogs.dir/#/files/ to /uploads/sites/#/
  • Change WordPress settings so it doesn't look in /files/ but in /uploads/sites/#/
  • In .htaccess or your nginx config file remove ms-files.php line/section
  • Search/replace the posts table for each site, changing /files/ to /uploads/sites/#/
  • 1
    great to hear you solved it, it would be nice if you could explain it a little bit more, because if this external link goes down, then the future readers of this answer will not know how you solved it ;-)
    – birgire
    Commented Sep 30, 2013 at 8:05

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.