Make WordPress Core

Opened 2 years ago

Last modified 19 months ago

#23755 new defect (bug)

Old /files/ support in new installs

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


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 (4)

comment:1 @unsalkorkmaz2 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.

comment:2 @SergeyBiryukov2 years ago

  • Component changed from Filesystem to Multisite

Related: #19235

comment:3 @Ipstenu2 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.

comment:4 @jeremyfelt19 months ago

  • Component changed from Multisite to Upload
  • Focuses multisite added
Note: See TracTickets for help on using tickets.