Make WordPress Core

Opened 11 years ago

Closed 8 years ago

#23755 closed defect (bug) (wontfix)

Old /files/ support in new installs

Reported by: unsalkorkmaz's profile unsalkorkmaz Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Upload Keywords: needs-patch
Focuses: multisite Cc:

Description

I moved a blog to a new network that using new upload folder system. Problem is: old /files/ links that using ms-files.php are not working.

My temporary fix:
Added in .htaccess:

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

Added ms-files.php:

define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/uploads/sites/{$current_blog->blog_id}/" );

above of:

$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );

Solution is working but I am not happy because it needs to edit core files. Is this working as intended? If it is, what is proper way to define BLOGUPLOADDIR for ms-files.php without breaking anything or editing ms-files.php

Change History (5)

#1 @unsalkorkmaz
11 years ago

oh btw i replaced all /files/ links inside blog. Problem is outside links like facebook posts. There is no way to edit those old posts and i need to support old /files/ links for that.

#2 @SergeyBiryukov
11 years ago

  • Component changed from Filesystem to Multisite

Related: #19235

#3 follow-up: @Ipstenu
10 years ago

  • Keywords needs-patch added

My fix for a site you move from old to new would be this:

1) Search/Replace the site ontent (which you did)
2) .htaccess redirect that site's /files/ since it should be the only one that has that issue (everyone else is 3.5 native)

That said, I'd love to see a plugin for this, since it gets asked now and then.

#4 @jeremyfelt
10 years ago

  • Component changed from Multisite to Upload
  • Focuses multisite added

#5 in reply to: ↑ 3 @jeremyfelt
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to Ipstenu:

2) .htaccess redirect that site's /files/ since it should be the only one that has that issue (everyone else is 3.5 native)

This is key and is similar to moving other types of sites into a WordPress environment.

I think having it documented in the codex is the right solution here rather than attempting to detect and provide an automatic fix in core.

RewriteRule ^([_0-9a-zA-Z-]+/)?siteN/files/(.+) wp-content/blogs.dir/N/files/$2 [L].

Note: See TracTickets for help on using tickets.