• Resolved Adam W. Warner

    (@awarner20)


    Hi all (and Ron!),

    I have a long standing Multisite install that has just a few subdomain sites on it and domain mapping has been working without issue for several years until the other day.

    On ONE of the subdomain sites, all the images are now broken on the frontend of the site and the file paths appear to be incorrect when viewed in the Media Library. Thumbnails are broken in the Media Library too.

    For example an image on the site has this URL:

    https://subdomainsite1.mywebsite.com/files/2011/11/theimagefilename.jpg

    The actual file exists under this location:

    ./wp-content/blogs.dir/9/files/2011/11/theimagefilename.jpg

    The host and the client claim to not have changed/updated anything including plugins/themes and I have confirmed what I can by looking myself.

    I’ve been digging in to try and determine the problem so to start I made a full db backup and then updated WP to 4.2.2 and all plugins that needed updating.

    The Domain Mapping plugin also needed updating so I went through that process (very carefully and multiple times) with no fix yet.

    I checked the .htaccess file to make sure it had the correct code for a Multisite installation and it appears that it did not. It seems to have had the old .htaccess rules.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    So I then updated the .htaccess file to include the new rules outlined under the “WordPress 3.5+” heading here:
    https://codex.www.ads-software.com/Multisite_Network_Administration#.htaccess_and_Mod_Rewrite

    Those rules are below.

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]

    However, the images are still broken and now another subdomain site on that install won’t load at all.

    If anyone can provide any additional guidance on what else I can try it would be greatly appreciated because at this point I’ve exhausted everything I know to try after searching/reading/implementing changes.

    Please help:)

    Adam

    https://www.ads-software.com/plugins/wordpress-mu-domain-mapping/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Ron Rennick

    (@wpmuguru)

    Answered on Twitter but posting here for anyone who finds the thread from a search. The second set of rules is correct except it’s missing the rule for the media which is

    subdomain install
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$2 [L]

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

    The rule should be added immediately after

    RewriteRule ^index\.php$ - [L]
    Thread Starter Adam W. Warner

    (@awarner20)

    Thanks so much Ron.

    A couple things:

    1. The .htaccess rules I used above were copied from the Codex page under the “WordPress 3.5+” heading. These don’t include the rule for media. Perhaps the Codex needs updating?

    2. Adding that rule seems to have had no effect as of yet. This is the entire contents of .htaccess as it is now:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]

    Was also pointed to this thread by Angela Meeker and will be trying the file replace part of her solution.

    https://www.ads-software.com/support/topic/what-should-be-the-path-to-images-on-subsites-worked-for-years-seems-broken?replies=13#post-7203920

    Thread Starter Adam W. Warner

    (@awarner20)

    Update:

    Using the .htaccess above and have replaced the wp-admin and wp-includes directories.

    Still broken images.

    Thread Starter Adam W. Warner

    (@awarner20)

    Update:

    Seems to be working now. Server cache perhaps?

    Thread Starter Adam W. Warner

    (@awarner20)

    Update: All is not well still.

    On the frontend of the site, the Featured Image thumbnails images are showing, but not the Featured Images for pages using the Genesis Slider.

    However, this seems to still be an issue with the image paths. I have uploaded new images to the Media Library and they still have the wrong image paths:

    https://subdomain1.mywebsite.com/files/2011/11/bio_conscious_2701.jpg

    In summary, I added the media rule to .htaccess as indicated above but that didn’t bring the images back.

    The hosting company said it was the difference between a “1” and a “2” in that rule. I have no idea what that means, but when their email came in, I went to the site and most of the images were there…until I discovered the Slider Featured Image on pages and also the new image upload paths still being incorrect.

    This was the hosting company email:

    It should be fixed now. There was an issue with your .htaccess file:

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

    It should have been:

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

    I’m not sure why that was changed as we do not modify user files nor has any changes been made to the (global) web server configuration in weeks+ on that particular server.

    Can you think of anything else that I can check or that I can go back to the host with to check on their end??

    Plugin Author Ron Rennick

    (@wpmuguru)

    Adam, sorry about the $1 vs $2 thing. That was a result of missing changing it while copy/paste & editing the rule.

    In a rewrite rule, $N is the pattern matched in the Nth set of parenthesis. For example

    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+)

    is

    RewriteRule ^(will be $1)?files/(will be $2)
    Thread Starter Adam W. Warner

    (@awarner20)

    No problem at all Ron, I really do appreciate the help. I’m just glad to know that I have the correct rules and I suppose that’s a good catch by the host.

    But this still hasn’t seemed to fix the image path issue as I described above. I’m really at a loss as to what to try next.

    I’m strongly considering just moving this single site out of the Multisite network into a single WP install using the built-in export/import tool to see what happens with the media files and to avoid spending more time on troubleshooting…

    Plugin Author Ron Rennick

    (@wpmuguru)

    What do the slider image URLs look like in the slider & what’s the URL for the images in the media library?

    Thread Starter Adam W. Warner

    (@awarner20)

    Hi Ron,

    Sorry for the delay in replying. We decided that migrating this subdomain site into it’s own single WP install was the best thing moving forward.

    I followed this tutorial and the site is back up now, and image paths have been fixed.
    https://code.tutsplus.com/tutorials/moving-wordpress-moving-a-site-out-of-a-multisite-network–cms-22772

    However, now I am seeing something very strange. There is no Add New option for plugins or themes and I cannot run any updates seen with update nags (like Genesis).

    It seems as though I’m still seeing subsite Admin pages within a single WP install.

    I was able to add a new “Admin” user and still get the same result with that.

    I also reinstalled WP with no success.

    Can you think of anything that I can try to correct this? Perhaps some kind of user meta attached to my Admin user that could be changed or deleted?

    This is super strange and if you need a better visual, I’m happy to make a video to show you what I’m seeing.

    Plugin Author Ron Rennick

    (@wpmuguru)

    Install Justin Tadlock’s role manager plugin (I forget the name) and look at the capabilities on the admin user. You are likely missing a cap or two.

    Thread Starter Adam W. Warner

    (@awarner20)

    Ron, didn’t find a Role Manager in Tadlock’s plugin listing on .org
    https://profiles.www.ads-software.com/greenshady/#content-plugins

    But, last night I was working with some people on my AWP post on the same subject and ran a SQL Query that I think has the information I need and from what I’m told everything looks OK.

    You can see the results of the original Admin user and the new Admin user below, both of which cannot see the “Add New” menus for plugins and themes.

    https://picpaste.com/Screen_Shot_2015-07-29_at_7.56.18_PM-KrIKMgYj.png

    https://picpaste.com/Screen_Shot_2015-07-29_at_8.00.44_PM-2FzAh0EO.png

    Here’s my role management plugin: https://www.ads-software.com/plugins/members/

    Thread Starter Adam W. Warner

    (@awarner20)

    Thanks Justin,

    Ok, so I’ve installed and have looked at the Administrator role and can see that it does not have the proper capabilities as it related to plugins and themes.

    https://picpaste.com/Screen_Shot_2015-07-31_at_10.20.54_AM-2Vd9bPDJ.png

    I’m going to edit this role and add those to see what happens, but the mystery still remains as to WHY the Admin role wouldn’t have these capabilities.

    Perhaps it’s “just one of those things” when exporting a subsite from a Multisite?

    Thread Starter Adam W. Warner

    (@awarner20)

    SOLVED

    Editing the Administrator Role using your Members plugin has brought back the Plugin/Theme capabilities!!!!

    THANKS FOR STICKING WITH ME ON THIS ONE GUYS!!!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Broken Images (and file paths) All of a Sudden’ is closed to new replies.