• Hi, I’ve been faced by what appears to be the common problem of images not displaying in my sub-sites. I’ve come up with a rewrite fix which works but as I’ve not seen this solution anywhere else (and it seems quite simple) I’m worried it may have unforeseen consequences!!

    Basically images are uploading to /wp-content/blogs.dir/** but for a reason I don’t understand WP makes the file URL: https://sub.domain/files – a folder that doesn’t exist!

    So I’ve just forced a wildcard rewrite (see below) in htaccess from /files/ to wp-content/blogs.dir.

    It appears to work well but I’m worried that WP must have separate destinations for upload path and file url for a reason so my question is:

    1. Is the fix likely to cause problems?
    2. Why does WP point to a non-existent folder (/files) in the first place?

    In case it helps my situation in detail is:

    Fresh install of 3.0
    Network of sites enabled and working well (subdomains)
    Images not displaying on subsites but fine on main blog

    Images upload OK and can be found in /wp-content/blogs.dir/****
    but in web browsers the image URL is /files/*** and as this folder doesn’t even exist the images don’t display.

    The problem occurs on both admin & public sides so its not a theme issue.

    In Network Admin > Sites > Edit > Settings I tried changing the settings of Upload Path (wp-content/blogs.dir/2/files) and Fileupload URL (http;//sub.domain/files) – to make the upload url the same as the upload path but this had no effect.

    I searched all the many forum posts but none seemed to give me the answer as my rewrite appears to be set up well and working fine.

    So eventually and I decided just to force the rewrite from /files to wp-content/blogs.dir using this code RewriteRule ^files\/?(.*)$ "http\:\/\/\(www\.\)\?\*\*\ All\ Public\ Domains\ \*\*\/wp\-content\/blogs\.dir$1" [R=301,L]

    Thanks a lot for any guidance!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Basically images are uploading to /wp-content/blogs.dir/** but for a reason I don’t understand WP makes the file URL: https://sub.domain/files – a folder that doesn’t exist!

    Don’t worry, that’s SUPPOSED to happen!

    Your .htaccess (for a subdomain install) SHOULD look like this:

    # 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

    See that line under uploaded files? That should handle this for you. Double check your .htaccess is right.

    While, /files/ doesn’t physically exist, WordPress uses Apache’s mod_rewrite and a .htaccess file to “create” it. It is done this way to make the URLs to media shorter and friendlier.

    It sounds like you are just masking a different issue with your fix. What it sounds like is that either mod_rewrite isn’t working or the .htaccess rules you have are not set up correctly. With the proper set up, you shouldn’t have to worry about the /files/ directory not being physically present — it should just work.

    Thread Starter Kieran

    (@cozzie)

    Thanks a lot both! I checked my .htaccess and it was right so I guess for some reason its not working for that particular rewrite.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Image display problem on sub sites: is this fix OK?’ is closed to new replies.