The MU forums have moved to WordPress.org

Upload File Path Incorrect - Try to access /files/ not /blogs.dir/1/files (17 posts)

  1. ConnorJack
    Member
    Posted 14 years ago #

    This is a little annoying >.<
    So I installed WPMU and it all installed fine. I added my theme and launched my site to positive comments: http://simoperations.com
    However, my media upload system is bugged. WPMU uploads images to the correct directory (wp-content/blogs.dir/1/files/) but when I try to insert them in a post it automatically tries to access them at (/files/). I can manually change it to the correct one, but that's not what I should need to do.
    Any help is appreciated. Thanks in advance.

  2. ConnorJack
    Member
    Posted 14 years ago #

    Found out a quick fix.
    Change (in 'wp-includes/wpmu-functions.php'):

    function fix_upload_details( $uploads ) {
    	$uploads['url'] = str_replace( UPLOADS, "wp-content/blogs.dir/1/files", $uploads['url'] );
    	$uploads['baseurl'] = str_replace( UPLOADS, "files", $uploads['baseurl'] );
    	return $uploads;
    }

    to:

    function fix_upload_details( $uploads ) {
    	$uploads['url'] = str_replace( UPLOADS, "wp-content/blogs.dir/1/files", $uploads['url'] );
    	$uploads['baseurl'] = str_replace( UPLOADS, "files", $uploads['baseurl'] );
    	return $uploads;
    }
  3. DeannaS
    Member
    Posted 14 years ago #

    Um...that's by design. You don't really want blogs.dir in your URL, do you? WPMU should automagically rewrite the URLS for you to get the correct images.

  4. robpannell
    Member
    Posted 13 years ago #

    I'm having this same issue, the media library & anywhere in the site that calls the media shows placeholders instead of images.

    If I click 'edit' from the library then it shows the expected image, so it clearly does know where they are, it just won't display them in the main library or in any pages/posts...

  5. SerU
    Member
    Posted 13 years ago #

    @robpannell

    You have problems with rewriting. Try to replace your existing .htaccess file with this one:

    RewriteEngine On
    RewriteBase /
    
    # Rewrite http://www.domain.com to domain.com
    RewriteCond %{HTTP_HOST} ^www\.(.*)
    RewriteRule ^(.*) http://%1/$1 [R,L]
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
  6. robpannell
    Member
    Posted 13 years ago #

    Thanks for the help, sadly it made no difference.

    My index.php is in the site root, calling the mu installation from a /mu folder. The .htaccess is inside that folder. Is that correct?
    I tried it in the site root as well with no joy.

  7. robpannell
    Member
    Posted 13 years ago #

    fyi, here is my original .htaccess

    RewriteEngine On
    RewriteBase /mu/
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    <IfModule mod_security.c>
    <Files async-upload.php>
    
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>
  8. andrea_r
    Moderator
    Posted 13 years ago #

    My index.php is in the site root, calling the mu installation from a /mu folder.

    This will break the blogs in mu. There is no workaround.

  9. robpannell
    Member
    Posted 13 years ago #

    That doesn't appear to be the case Andrea,

    I just moved the index.php back into the /mu folder & made sure mu knew that, so it's now all set up as normal and yet everything is exactly the same. Everything works fine bar this media issue, regardless of where the index is placed.

    The only difference is that I now obviously get '/mu' showing in the URL in my address bar.

  10. robpannell
    Member
    Posted 13 years ago #

    I've just remembered, I have another mu installation set up that way (http://h2oservices.org) which is running with no issues at all that has the index in the root and installation in a subfolder.

    I'm not meaning to argue with you, it's just that it seems it does work...

  11. andrea_r
    Moderator
    Posted 13 years ago #

    Well, code-wise and from the devs, it shouldn't work ;) so you're not arguing with me me, you're arguing with them. :D I just pass this stuff on.

    (see: multiple threads where people try to get this working and fail)

    At any rate, the media issue is separate.

    What placeholders are they showing, and what URL is it generating when the image is not showing properly?

    A link would be handy indeed.

  12. robpannell
    Member
    Posted 13 years ago #

    Alas I can't link you, as it's running as an intranet on our local network, not online.

    The url it's looking for the images at is http:/mydomain.net/mu/files/2010/03/image.jpg
    The actual path being /mu/wp-content/blogs.dir/1/files/2010/03/image.jpg which I've verified.

    A screenshot of the placeholder:
    Link

  13. andrea_r
    Moderator
    Posted 13 years ago #

    Right, which is how it's supposed to work (at least with the links you've supplied.)

    Nitpick: that's not a placeholder image, that's a "image not found" image in windows. ;) Can you actually visit http:/mydomain.net/mu/files/2010/03/image.jpg? Plunk that in, and you'll get a huge hint.

    The urls get rewritten based on the rules in the default .htaccess file. Compare your with htaccess.dist, they should be almost identical.

  14. robpannell
    Member
    Posted 13 years ago #

    I get the 'Object not found' with a 404 error.

    My .htaccess is identical to the htaccess.dist except the Rewrite base is /mu rather than /

  15. andrea_r
    Moderator
    Posted 13 years ago #

    There are other people who have had this issue where the image rewrites don't work, but the page permalinks do, and I haven't been able to track it down.

    except in one case where there was a www collision.

    So without being able to see anything at all, there's really not much I can do.

  16. robpannell
    Member
    Posted 13 years ago #

    d'oh. Ok, I'll keep plugging away with it & let you know if I find anything.

    Thanks for your help so far. Much appreciated.

  17. robpannell
    Member
    Posted 13 years ago #

    Finally got this sorted. It turned out that when my manager set up the apache server he defined some rules in the httpd.conf, and had made a typo in the file path for the directory mu is in.

    It all works now!

    Thanks for your help.

About this Topic

  • Started 14 years ago by ConnorJack
  • Latest reply from robpannell