WordPress.org

Support

Support » Multisite » Images /wp-content/blogs.dir/[id]/files/image.jpg not displaying

Images /wp-content/blogs.dir/[id]/files/image.jpg not displaying

  • Wykydtron
    Member

    @chaos1

    On mapped domains most images display the src attribute with http://domain.com/wp-content/blogs.dir/3/files/2012/03/image.jpg – 404 error (for whatever reason these images are now not showing up.)

    However, if I change the URL to:
    http://domain.com/files/2012/03/image.jpg
    The image will appear. Is this something recent in 3.4.2? Am I going to have to go through and fix all these img src attributes?

    I double checked the .htaccess, below is the standard WP .htaccess I have. Note, excluded is mod_expires block of code.

    Any help would be appreciated.

    ————–
    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]
    RewriteRule . index.php [L]
    # END WordPress
    ————–

Viewing 4 replies - 1 through 4 (of 4 total)
  • Frans Andersson
    Member

    @wpfranner

    The link /wp-content/blogs.dir/3/files/2012/03/image.jpg is the file path as seen from a file system (like via FTP). After it passes through the .htaccess mod rewrite it becomes /files/2012/03/image.jpg.

    WordPress can (at least in sub folder installs) display images that are linked via the file path even on mapped domains. I have never seen this work on sub domain installs like yours when a site is mapped with a domain. I could be wrong though…

    In any case – the correct way to link images is with this syntax /files/2012/03/image.jpg.

    Wykydtron
    Member

    @chaos1

    Yeah, subdomain installs it should work fine. For whatever reason, image paths like /wp-content/blogs.dir/3/files/2012/03/image.jpg worked fine (and for whatever reason the Media Library would display it this way).

    It seems like a recent change (maybe 3.4.2?) broke these, I originally assumed caching or .htaccess was the issue, however I started leaning towards .htaccess or a change in 3.4.2 that I’m unaware about. Hmm.. There may be a lot of effected websites that I may need to fix.

    Wykydtron
    Member

    @chaos1

    I looked at the blogs.dir directory and found a .htaccess file that contained the following code:

    Order deny,allow
    Deny from all
    <Files ~ "^[0-9A-Za-z]+\.(jpeg|gif|png)$">
        Allow from all
    </Files>

    The issue is the regex. It only allows 0-9, A-Z, a-z, and does not include dashes and underscores. The appropriate .htaccess file should read as:

    Order deny,allow
    Deny from all
    <Files ~ "^[0-9a-zA-Z.\-\_]+.(jpg|jpeg|gif|png)$">
        Allow from all
    </Files>

    Example; if using the first .htaccess, logo-300×300.jpg would be denied but logo.jpg would work fine. However if you use the second .htaccess example, logo-300×300.jpg AND logo.jpg would work fine.

    There shouldn’t be any .htaccess in your blogs.dir actually, unless you added one yourself (WP doesn’t come with one)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Images /wp-content/blogs.dir/[id]/files/image.jpg not displaying’ is closed to new replies.