Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to replace "wp-content/blogs.dir" with "media" for attachment permalinks in a multisite environment?

This is how links look now: -or-

Ideally this is how the would look: -or-

Thank you!

share|improve this question
can you post the code you are using to extract the initial URL? – Mild Fuzz Jul 5 '11 at 19:51
I'm using a [gallery] template tag. – mattrepublic Jul 5 '11 at 19:53
Next Gen Gallery? – Mild Fuzz Jul 5 '11 at 19:57
Just the basic WP Gallery short-tag. – mattrepublic Jul 5 '11 at 20:17
Do you have pretty permalinks turned on? – EAMann Jul 5 '11 at 21:31

2 Answers 2

up vote 2 down vote accepted

Actually ... the blogs.dir part isn't used except for internally.

Let's say you have a network with two sites - and The files will be located in (respectively):


The blogs.dir directory is where the images exist physically, yes, but your .htaccess file is routing the virtual directories I just listed above to the correct location.

I'm guessing you're manually putting together the URLs you reference above ... because that's not how Multisite is set up to work by default.


I just tested this on my own network installation to give you a specific example.

My main blog is (custom domain mapped to a subdomain network installation - is the same site). A recent post with images: How to Publish a WordPress Plugin - Subversion.

The first image in the post is:

But an alternate link that also works:

WordPress automatically maps the /files directory for this site to /wp-content/blogs.dir/2/files via the .htaccess file.

So your image permalinks will work with the shortened version ... there's nothing you need to do there. It sounds like your problem is actually with the way the [gallery] shortcode outputs content.

share|improve this answer
Not much of an answer ;) – Mild Fuzz Jul 5 '11 at 20:19
That's how its working for me, I'm not making it up. :) <!-- see gallery_shortcode() in wp-includes/media.php --> <div id='gallery-1' class='gallery galleryid-476 gallery-columns-6 gallery-size-photostream'><dl class='gallery-item'><dt class='gallery-icon'><a href='‌​g' title='650026_x640_21'><img width="143" height="107" src="‌​x107.jpg" class="attachment-photostream" alt="650026_x640_21" title="650026_x640_21" /></a></dt></dl> – mattrepublic Jul 5 '11 at 20:21
This is the correct answer. Your site shouldn't be using /wp-content/blogs.dir at all. That gets replaced with /files in a multisite setup. – Otto Jul 5 '11 at 21:33
Thanks guys, I must have something funny going on. – mattrepublic Jul 5 '11 at 22:13

Take a look into core:

/wp-includes/ms-default-constants.php > line 21 : UPLOADBLOGSDIR
/wp-includes/ms-default-constants.php > line 27, 28 : BLOGUPLOADDIR
/wp-admin/includes/ms.php > line 91 ; apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );

I don't know much about WPMU/Network installs, that's such what come up from a cross file search.

share|improve this answer
Thanks Kaiser for the direction – mattrepublic Jul 5 '11 at 22:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.