Updated after Andrew Nacin asked me “Why are you suggesting they replace ‘wp-content/blogs.dir/1/files/’ into their post content, instead of /files/?” (Answer: Because when I did this on my first site, about a year ago, I majorly goofed my SQL search/replace and shot myself in the foot For some reason, that made me think ‘files is bad! Blogs.dir is good!’ which … it’s not. Really, blogs.dir is fewer redirects, but that’s really about all I can say. So this has been edited. Thanks!)
In generic WordPress single installs, your images are, by default, located in a folder called
uploads off the
wp-content folder, and tend to look like this:
wp-content/uploads/YYYY/MM/image.jpg. When you use MultiSite WordPress, the files are now in
wp-content/blogs.dir/#/files (where the # is the blog number). If you upgrade from Single to MultiSite, you can leave the files for Blog #1, i.e. your primary blog, where they are to no ill effects. Or you can move them.
I’m not going to be using # as a placeholder, as for most people this blog will be 1. If for ANY REASON yours is not, change it.
Also, I can’t stress this enough, you don’t have to do this! Your images will be just fine where they are, but if you want to move them, you can. Enough people have asked on the WordPress.org support forums that I bothered to consolidate my notes on this, however.
Oh, and backup. Always backup before you start this sort of thing, otherwise you’re a reckless fool.
Step 1 – Move the OLD files
This is easy. Copy or move the files to
While you’re in there, remember to set the folder writable so you can update files later. Your images will now look like
wp-content/blogs.dir/1/files/YYYY/MM/image.jpg – Make a note of this, you’ll need it in a second.
Step 2 – Teach WordPress where the OLD files are
There are two main ways to do this:
Edit the Database
If you have phpMyAdmin or are savvy at command line SQL, just go ahead and run the replace command:
update wp_posts set post_content = replace(post_content, 'wp-content/uploads/', 'files/');
Now someone here might go “Hang on, I put my files in
blogs.dir/1/files and you’re saying to tell WordPress to look in
files! What gives?” What gives is what Andrew reminded me! WordPress MultiSite parses files from ‘files.’ The shortest explanation is ‘It’s an .htaccess trick.’ The longer explanation is it’s own blog post.
If you don’t like the idea of SQL, get a search and replace plugin like Search and Replace or Search RegEx and install it. Then search for
wp-content/uploads/ and replace with
wp-content/files/ to change the database.
In both database cases, you’ll want to check changes all over the place. For
post_content, and then go through
wp_postmeta and edit the meta_value fields.
That’s a lot of work, and odds are you’re still going to miss something. You can also be really lazy and add this to your .htaccess file, before the WordPress stuff:
# Moved Images RewriteRule ^wp-content/uploads/(.*)$ http://domain.com/files/$1 [L,R=301]
That redirects things quietly. It’s probably not the best way, but like I said, I’m lazy. If I was doing this for a client, I’d probably do both the database fix and the .htaccess, to catch any stragglers.
Step 3 – Tell WordPress where to put the NEW files
In that new screen, scroll down and look on the left for Upload Path – You want to change that to
You also want to change Fileupload Url to be
http://domain.com/files (this will hold true even if you’re using subfolders or subdomains).
If you see Upload Url Path, you can change if to
http://domain.com/files as well, though it appears to be depreciated and no longer used.
Step 4 – There is no Step 4
That’s it! You’re done!