WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Media uploads work on root site of subdir multisite, but not child sites (12 posts)

  1. dunxd
    Member
    Posted 3 years ago #

    I setup a Network using subsites a while ago, but didn't start using it till recently. However I did upgrade from 3.0 to 3.1.2 before trying uploads.

    Access to the sites works fine. However, uploaded media files are not appearing on child sites, although they appear in the file system. Uploaded media works fine for the root site.

    E.g. subsite: http://blogs.ddict.co.uk/garden
    Uploaded a file. It appears in file system at /home/dunx/www/wp_multi/wp-content/blogs.dir/7/files/2011/05/dunxPainting-weeer.jpg. It can be accessed directly at http://blogs.ddict.co.uk/wp-content/blogs.dir/7/files/2011/05/dunxPainting-weeer.jpg. This shows that the upload mechanism and permissions are set fine. However, WordPress expects the file to be accessed at http://blogs.ddict.co.uk/garden/files/2011/05/dunxPainting-weeer.jpg which is returning nothing at all.

    So I suspect something is not right with the rewrite rules in .htaccess:

    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]

    These rules don't reference blogs.dir, so I suspect they may be wrong. Can anyone put me in the right direction?

  2. ethilanka
    Member
    Posted 3 years ago #

    this is similar to my issue faced on little while ago and still exists without a solution... better you refer my thread and grab some useful to fix your issue.... Let us update if you got something...

    check this out

    Cheers..!

  3. Actually, this rule DOES secretly mention blogs.dir:

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

    It's part of a double redirect. It's supposed to work like this:

    you point to http://blogs.ddict.co.uk/garden/files/2011/05/dunxPainting-weeer.jpg

    WP translates that to http://blogs.ddict.co.uk/wp-includes/ms-files.php?file=files/2011/05/dunxPainting-weeer.jpg

    And parses that as http://blogs.ddict.co.uk/wp-content/blogs.dir/7/files/2011/05/dunxPainting-weeer.jpg

    Since the second URL bombs out as a 404, however, let's start at the basics. Is wp-includes/ms-files.php on your server?

    (ethilanka - similar, but not the same - your problem is your .htaccess isn't being read, please don't hijack other people's topics.)

  4. dunxd
    Member
    Posted 3 years ago #

    wp-includes/ms-files.php exists. The 404 message is generated in ms-files.php for a few different reasons. This one looks most likely:

    '$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
    if ( !is_file( $file ) ) {
    status_header( 404 );
    die( '404 — File not found.' );
    }
    '

    Edited the die command to read:

    die("404 — File not found. $file" );

    And then I see what it is choking on:

    404 — File not found. /home/dunx/www/wp_multi/wp-content/blogs.dir/1/files/files/2011/05/dunxPainting-weeer.jpg

    That is completely broken. Breaking it down into what is generating $files:

    BLOGUPLOADDIR = /home/dunx/www/wp_multi/wp-content/blogs.dir/1/files/
    str_replace( '..', '', $_GET[ 'file' ] ) = /2011/05/dunxPainting-weeer.jpg

    Hmm - how did that extra /files/ get in there?
    Where did it get /home/dunx/www/wp_multi/wp-content/blogs.dir/1/files as a constant from?

    I installed/upgraded from svn (svn sw http://core.svn.wordpress.org/tags/3.1.2/ .)

  5. Go in to Network Admin -> Sites and EDIT the site this is happening on. Click on the 'Options' tab.

    What are the values for:
    * Upload Path
    * Fileupload Url
    * Upload Url Path

  6. dunxd
    Member
    Posted 3 years ago #

    Upload Path: wp-content/blogs.dir/7/files
    Fileupload Url: http://blogs.ddict.co.uk/garden/files
    Upload Url Path: empty

  7. Well those are correct. Damn it. I can't figure out why it would give you THIS

    404 — File not found. /home/dunx/www/wp_multi/wp-content/blogs.dir/1/files/files/2011/05/dunxPainting-weeer.jpg

    Unless you have a weird redirect plugin or line in your .htaccess.

  8. dunxd
    Member
    Posted 3 years ago #

    @Ipstenu - Thanks for the assistance yesterday. I did another svn install of wordpress and this time it seems to work fine. Not worth the time to investigate further, but I really appreciate the time you gave me.

  9. Sure thing.

    If the new install works, then maybe it was a corrupt file? I dunno. I hate when they do that :(

  10. boundforhome
    Member
    Posted 2 years ago #

    I don't know if it's correct etiquette to hijack this thread, but I have the *exact* same problem occurring on my multisite install.

    Couple of differences: I'm running WP 3.2.1, and I'm using the subdomain multisites rather than subdirectory.

    However, exact same problem occurring - a 404 on the /wp-includes/ms-files.php parsing. Has this become a known issue, or is there any understood fix/workaround for this?

    Jason

  11. dunxd
    Member
    Posted 2 years ago #

    Did you try reinstalling? That worked for me, so all I can think might have happened was that a file was corrupted, and when I reinstalled, it wasn't.

  12. boundforhome - Any time you have to say 'except for...' or the word 'difference' you should be making a new post since it may not be the same. (Also if the post is resolved, you should always make a new one)

    Anyway. The problem is that your install isn't redirecting properly. The CAUSE in dunxd's case was a corrupt file.

Topic Closed

This topic has been closed to new replies.

About this Topic