The MU forums have moved to WordPress.org

404 on images (25 posts)

  1. davidspan
    Member
    Posted 9 years ago #

    Okay I've been working on this just about all day. I installed WordPress MU today and started testing. I have only found 1 problem and have searched the forums here and Google for a solution to no avail.

    I have tried many things and nothing seems to work. I'll try and step you though what I have done and my current settings.

    Here is the problem: images uploaded via wordpress are being uploaded and to the proper directory. However when I view them I get a 404 error.

    Here is my htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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>

    <IfModule mod_security.c>
    <Files async-upload.php>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>

    So with this config every image within wp-contents goes 404 also blogs.php as well.

    I have used both calling them direct:
    http://mydomain.com/wp-content/blogs.dir/2/files/2009/01/images.jpg
    and via the blogs.php script:
    http://mydomain.com/wp-content/blogs.php?file=/2009/01/images.jpg

    I have checked permissions have reset them, re-uploaded them and tried just about every thing I could thank of.

    no when I comment out:
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    I am able to view the image via
    http://mydomain.com/wp-content/blogs.dir/2/files/2009/01/images.jpg

    but of course not with blogs.php

    All the other rewrite urls are working so I have no idea what is going on. I have tried so many things my brain is about to melt. I know I must be missing something....

    Also I'm not using vhost so http://mydomain.com/blog1

  2. cafespain
    Member
    Posted 9 years ago #

    You should be able to see the images with the blogs.php url even if you have disabled the files rewrite rule.

    I usually remove the condition statements:
    <IfModule mod_rewrite.c>, etc
    as I know I have the relevant modules installed and so were not needed. I did have some issues with them a while ago (can't remember exactly) so try removing them and see if it changes anything.

  3. davidspan
    Member
    Posted 9 years ago #

    Thanks cafespain,

    I tried that, still no go.

  4. cafespain
    Member
    Posted 9 years ago #

    I've just checked my htaccess, I'm using an older file which is obviously a hangover from an older installation and it seems to be missing the middle line for the section relating to the uploaded files.

    Try stripping the line:
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*

    So you are left with:

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

  5. cafespain
    Member
    Posted 9 years ago #

    #posted again just in case it wasn't the cache that ate it #

    I've just checked my htaccess, I'm using an older file which is obviously a hangover from an older installation and it seems to be missing the middle line for the section relating to the uploaded files.

    Try stripping the line:
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*

    So you are left with:

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

  6. cafespain
    Member
    Posted 9 years ago #

    aaargh this caching is killing me

  7. davidspan
    Member
    Posted 9 years ago #

    Nope still no go.

    I thank it might be a problem with my webhost. I see a few have suggested SynHosting on the forums here. I just signed up an account with them. Then I'll test from there.

    Thank you cafespain

  8. cafespain
    Member
    Posted 9 years ago #

    It's the inconsistency that gets me - surely the same rewrite rules should work the same way on each server....

    Let us know if it works on the new host.

  9. davidspan
    Member
    Posted 9 years ago #

    Yea it worked right out of the box with the new host.

    The funny thing is when ask asked the other host they said sure it would work just fine. After talking with a few others who had tried to do the same they ran into the this problem as well.

    I spent most of the day yesterday screwing around with it and today on the new host I had it up and running in less than an hour. And that includes most of the testing.

    I also got buddypress installed. Now it's time edit the themes and further bug testing

    Thanks again cafespain for your help

  10. andrea_r
    Moderator
    Posted 9 years ago #

    What host did you have issues on?

  11. davidspan
    Member
    Posted 9 years ago #

    for some reason there was a problem with the rewrite mod when it came to working with images in the wp-contents directory....

    as stated above:
    images uploaded via wordpress are being uploaded and to the proper directory. However when I view them I get a 404 error.

    But I'm not having a problem with it on the new host...

  12. renanivo
    Member
    Posted 9 years ago #

    I had the same problem. It happened because the one of the rewriting rules changed the behavior the wp-content/blogs.php file. To fix it, I changed my .htaccess file to:

    RewriteEngine On
    RewriteBase /

    #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]
    RewriteCond %{REQUEST_URI} !^.*/wp-content/.*$
    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>

    It is working to me
    Somebody know if I'll have future problems?

  13. renanivo
    Member
    Posted 9 years ago #

    I found an error in my fix. I works at the main site, but the subdomains still has the bug. I think the rewrite engine isn't forwarding requests to other folders. To fix it (again) I changed my .htaccess file to:

    RewriteEngine On
    RewriteBase /
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) 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>

    After do it I created a file blogs.php at the same folder of the .htaccess file. The blogs.php file has the content:

    <?php
    require('wp-content/blogs.php');

    It's working to me

  14. kremdela
    Member
    Posted 9 years ago #

    For anyone else who finds this and is having problems...
    Make sure your .htaccess is being used.

    In your Virtual Host, you'll need:
    AllowOverride All

  15. mikerodger
    Member
    Posted 9 years ago #

    Appologies everyone, but I think I've tried all of the solutions here and I still can't get my images to show up. Images upload properly, get to the proper folder but don't show in the media library or in the posts.

    Fresh install of WPMU - 2.8.4a

    Permissions are set properly - I've tried all the way up to 777 and the user/group is the proper one for the apache server

    I have tried all of the .htaccess files including the ones above, the default and the one andrea_r can recite from memory.

    My sites are running on a Rackspace Linux server running Apache 2.2.3. Standard WP installs work fine.

    I have changed the Apache config files as above and as per the install instructions.

    .htaccess is working for renaming the post URL's.

    Plugins are all off.

    I'm going to keep looking and if I figure it out, I will post here, but I've been working on it for a couple days and so here I am.

    Thanks.

  16. andrea_r
    Moderator
    Posted 9 years ago #

    (I did giggle a bit. I don't do it *all* from memory...)

    Can you call up the images without the re-written url?

    Ex: wp-content/blogs.dir/1/files/2009/09/image.jpg ?

  17. tim.moore
    Member
    Posted 9 years ago #

    Also, to ensure your plugins aren't causing a problem, remove them. Even when they are deactivated, they may cause problems.

  18. mikerodger
    Member
    Posted 9 years ago #

    I can call up the images at domain.tld/17/files/sample.jpg

    "17" in this case is the blog ID #

    I set "Uploads Use Yearmonth Folders" to "0" hoping that would solve the problem.

    The File URL in the Media Library shows domain.tld/files/sample.jpg

    Remove the plugins? Can I hold off on that step just for a bit to see if something else fixes my problem?

  19. mikerodger
    Member
    Posted 9 years ago #

    All plugins removed, no change.

  20. mikerodger
    Member
    Posted 9 years ago #

    davidspan, I don't know if you're still monitoring this or not, but if so I have a question. When you switched to the new host, is wpmu automatically generating your .htaccess file or are you using one of the versions above?

    On the Permalink Setting page, I get the message:

    If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.

    However, I have the permissions set high for the .htaccess file, so I don't know why wpmu says it is unwritable.

    If you switching hosts allowed wpmu to automatically modify the .htaccess file, perhaps that is what changed when you changed hosts.

    If that's the case, anyone know what I need to change on my server in order to allow that to happen?

  21. davidostrow
    Member
    Posted 9 years ago #

    Renanivo,

    You solution worked for me. I had the same issue as the rest, and spent 8 hours yesterday trying to figure it out. Today I used a different search and your suggestion worked.

    Thanks for being so smart.

    Dave

  22. eduardo.augusto.santos
    Member
    Posted 9 years ago #

    Renanivo,

    Thanks for the solution. It worked for me too.

  23. jittopjose
    Member
    Posted 9 years ago #

    Thank alot..
    I waisted almost 2 days behind this problem.. Thanks alot Renanivo for the solution
    Jitto P.Jose

  24. justinkomhyr
    Member
    Posted 9 years ago #

    I have seen this issue many times and it has been linked to incorrect ownership of the wp-content/blogs.dir file.

    Owners should be set to nobody:nobody

    The apache line to fix this would be chown -R nobody:nobody blogs.dir
    An easy way to do this is ftp using winsp and then selecting commands and then open terminal from the top left. Have the wp-content folder already open before you do this. Then type in chown -R nobody:nobody blogs.dir

    If you can't do this on your server then have your hosting company do it.

  25. thejoemeister
    Member
    Posted 8 years ago #

    Oh happy day! Thanks, Renanivo

    Worked perfect!

    JOE

  26. MikeMu
    Member
    Posted 8 years ago #

    Thank you--you saved me so much time Renanivo. I don't understand why it worked. But it did.

  27. alexmaximo
    Member
    Posted 8 years ago #

    Renanivo's fix works like a charm! Any idea on what server setting is causing this?

    I noticed that images called up by plugins in the plugin directory is also affected e.g. SI Captcha is called up by a php funciton as well.

About this Topic

  • Started 9 years ago by davidspan
  • Latest reply from alexmaximo