Wordpress Multiuser + htaccess + uploading images = 404 links...
June 15, 2011 7:36 PM   Subscribe

So I'm running Wordpress 3.0 multiuser-enabled, but I can't get any of the images (which all upload) on any blog but the first to display correctly. The only solution I've found online hasn't worked for me, and I think it's an .htaccess problem.

My .htaccess file says this (from Wordpress's setup instructions -- I'm using the sub-domain setup):


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]

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


What happens is I'll upload an image to blog 2, and it will show up if I load domain/wp-content/blogs.dir/2/files/image.jpg, but not domain/wp-content/uploads/image.jpg. The first one is the actual location on the server, whereas the second one is what Wordpress produces and what that htaccess file is supposed to make work.

I've used the paid support by my web host and I've tried the Wordpress.org support forums multiple times each, and I've Googled my brains out, but no dice. I tried to learn how to write .htaccess by myself, but as far as I can tell it looks like that should be working. Wordpress support says my host just isn't reading the htaccess file, and my host says that that is "erroneous," but I'm pretty sure it's being read because all of the permalinks work well-- it's just file uploads that can't be read on the subsidiary blogs.

Help? Please?
posted by dubadubowbow to Computers & Internet (14 answers total) 1 user marked this as a favorite
 
and it will show up if I load domain/wp-content/blogs.dir/2/files/image.jpg, but not domain/wp-content/uploads/image.jpg.

You may want to double check that second URL. On my Wordpress MU install, the links are of the form subdomain.example.com/files/2011/06/image.jpg. That URL would point to the actual file location of \root_wordpress_folder\wp-content\blogs.dir\2\files\2011\06\image.jpg.
posted by Nonsteroidal Anti-Inflammatory Drug at 7:42 PM on June 15, 2011


Response by poster: Yeah, it's wp-content/uploads/image.jpg for sure. I don't know why there aren't yearly and monthly subdirectories, but I'd like those too, but I'm trying to just get the images to show up for now. But yeah, that's how it is.
posted by dubadubowbow at 7:47 PM on June 15, 2011


Sorry, I almost left that out because you didn't have them. My point wasn't the dates, but rather the "files" folder. Based on your file location of "domain/wp-content/blogs.dir/2/files/image.jpg", I would assume that you could load that with "sub.domain/files/image.jpg". I'm wondering why it's generating an "uploads" folder.

I can't VPN into my server tonight, but I should be able to check it tomorrow to see what my .htaccess looks like, and could probably figure out a way to determine if your host is reading it or not.
posted by Nonsteroidal Anti-Inflammatory Drug at 7:57 PM on June 15, 2011


The easy way to find out whether the .htaccess file is being read is by deliberately breaking it. Add a spurious command on its own line (eg, "uhdfighgf"), reload the site in your browser, and if you get a server error, the .htaccess file is being read: Remove the spurious command, and now you know you're getting somewhere.
posted by ardgedee at 7:58 PM on June 15, 2011


Response by poster: @NSAID-- That's really interesting. When I try domain/wp-content/files/image.jpg, I get a white page that says "404 — File not found," looking like Wordpress probably produced it, whereas if I try the one with "uploads" in it, then I get my theme's default 404 page. So it looks like that's a problem, too, but it still doesn't take me to the image.

@ardgedee-- That worked. It broke and gave me an error saying it might have something to do with "An invalid or inaccessible .htaccess file," and I fixed it and it's working again. So there's that, at least.
posted by dubadubowbow at 8:04 PM on June 15, 2011


Response by poster: Also @NSAID, I'd appreciate that a lot, thanks.
posted by dubadubowbow at 8:06 PM on June 15, 2011


> That worked. It broke and gave me an error saying it might have something to do with "An invalid or inaccessible .htaccess file," and I fixed it and it's working again.

Make sure this .htaccess trick works for requests from every subdomain you're trying to access the image directory from.

So, eg, if your wpmu installation is example.com, and the .htaccess file is at the www.example.com webroot, see if things break in exactly the same way when you request something.example.com, blog2.example.com, and so on.

One shared hosting service I use frequently will only respect the .htaccess file at the webroot of the specific domain or subdomain being requested. I haven't set up any wpmu installs at this service, but since wpmu requires the server to resolve subdomains to virtual directories, something's got to be configured.

Check the user forums for your web host to see if anybody else has problems and/or workarounds with running wpmu (or similar CMSes like Drupal) across multiple domains or subdomains.
posted by ardgedee at 7:03 AM on June 16, 2011


Here's what I've got, same as your first two thirds:
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]



The only other red flag I'm seeing right now is your version number. I'm at the current version (3.1.3), and while I can't say that it's going to magically fix things, they do fit in a lot of bug fixes and such. It might be worth upgrading just to see what that does. It's also strongly recommended due to security.

Other than that, can you see images at all? Once you upload them, for example, in the Media Library? What about if you include something in a blog post? It sounds like you can't, but if you can see them anywhere that would be a great way to figure out what Wordpress is thinking.
posted by Nonsteroidal Anti-Inflammatory Drug at 7:08 AM on June 16, 2011


Response by poster: @NSAID -- Yes, I can see them, but only in their actual folder location. I.E.,
myblog2.com/wp-content/blogs.dir/2/files/image.jpg
myblog3.com/wp-content/blogs.dir/3/files/image.jpg
Etc. Only broken images appear anywhere on Wordpress though (media library, uploads page, new post page, actual themed output page, everywhere), I can only see that they are uploading at all by manually checking.

I don't know if this is helpful, but I can access the files from any domain. For example:
myblog2.com/wp-content/blogs.dir/2/files/image.jpg
myblog3.com/wp-content/blogs.dir/2/files/image.jpg
Those two both work the same way.

@ardgedee -- I've tried the forums, and no dice. They also have a wiki and an extensive FAQ, but no luck there either.

I did it again for subdomains, and nothing was read there either.
posted by dubadubowbow at 11:08 AM on June 16, 2011


Response by poster: @NSAID -- Also, I did upgrade to 3.1.3, and that unfortunately didn't work either.
posted by dubadubowbow at 11:11 AM on June 16, 2011


I don't know if this is helpful, but I can access the files from any domain. For example:
myblog2.com/wp-content/blogs.dir/2/files/image.jpg
myblog3.com/wp-content/blogs.dir/2/files/image.jpg
Those two both work the same way.


Huh. That should not happen.


How do you have your domains set up? Is it with the Domain Mapping plugin?
posted by Nonsteroidal Anti-Inflammatory Drug at 3:02 PM on June 16, 2011


Response by poster: Yes, I am-- I was using 0.5.3 but I upgraded to 0.5.4 just now to see if it helped, but nothing changed still.

(Jeez, I don't know where all of these problems are popping out from!)
posted by dubadubowbow at 3:50 PM on June 16, 2011


Out of curiosity, which hosting provider are you using?
posted by Nonsteroidal Anti-Inflammatory Drug at 7:48 AM on June 17, 2011


Response by poster: NearlyFreeSpeech.net. No complaints about them whatsoever, otherwise.
posted by dubadubowbow at 1:41 PM on June 17, 2011


« Older Crotch-Rocket Riders: Help Me Pimp My lil Bro's...   |   US student going to be living in Germany for a... Newer »
This thread is closed to new comments.