5

Setup 1 :

The general subdomain/custom-domain based multisite setup for child network sites has its upload directory like this

/home/example1.com/public_html/wp-content/uploads/sites/8/2022/01/logo.png

example1.com : the primary WordPress multisite network

example2.com : the child network site with site id 8 under example1.com

This file can be accessed from the child network site from the following URL

https://www.example2.com/wp-content/uploads/sites/8/2022/01/logo.png

the general .htaccess file for subdomain based network site is following


# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

Setup 2 :

In a subdomain/custom-domain based multisite setup I've got this upload directory, it uses blogs.dir instead of uploads directory

/home/example1.com/public_html/wp-content/blogs.dir/8/files/2022/01/logo.png

The child network site has following file path

example2.com/files/2022/01/logo.png

.htaccess of this setup is here


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

I've tried using this for new general installation where the intended upload path is blogs.dir but having this .htaccess does nothing.

There is no such difference in wp-config.php file that could affect this setup


/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );

define( 'DOMAIN_CURRENT_SITE', 'www.example1.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

define('ADMIN_COOKIE_PATH', '/'); // removed for hide my wp ghost plugin

define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

define( 'NOBLOGREDIRECT', '/404' );

Both setup was done by me and I don't remember any settings inside the dashboard that could change this. Permalinks checked; all possible settings inside the dashboard checked.

General multisite installation exposes site id in media path like this

https://www.example2.com/wp-content/uploads/sites/8/2022/01/logo.png

The goal is not to expose site id in media path example2.com/files/2022/01/logo.png

What am I missing here?

1
  • 1
    Shouldn't there be something like define( 'UPLOADS', 'wp-content/blogs.dir' ); in wp-config.php?
    – Futuritous
    Commented Jan 25, 2023 at 11:48

3 Answers 3

3
+25

I can see a few possibilities:

  1. Custom Uploads directory (blogs.dir) is not properly setup in wp-config.php. While wp-content/uploads is by default taken by WordPress, wp-content/blogs.dir must be setup somewhere. I don't see it in your provided code anywhere.

  2. A custom directory like blogs.dir can be symbolically linked to wp-content/uploads. Check if any of your previous setup has such symbolic links in the filesystem. You may connect to the server (SSH) and run the shell command like ls -alh to check symlinks.

  3. .htaccess file not properly routing requests for the files located in the blogs.dir directory. Double-check that the mod_rewrite module is enabled in your Apache server and that the .htaccess file has the correct permissions to be read by the server.

Additionally, you may want to check your server's error logs for any related issues.

0

Perhaps this may help -

First, locate the wp-config.php file in your WordPress installation directory.

Then, add the following code to the wp-config.php file, replacing 'your-site-id' with the ID of the site you want to use the 'blogs.dir' directory for:

define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir/your-site-id/files' ); add_filter( 'upload_dir', 'wpse_upload_dir' ); function wpse_upload_dir( $param ) { $param['path'] = ABSPATH . UPLOADBLOGSDIR; $param['url'] = get_home_url() . '/' . UPLOADBLOGSDIR; $param['subdir'] = ''; return $param;
0

It seems blogs.dir is only used during wordpress 3.0-3.4.2 . https://developer.wordpress.org/advanced-administration/multisite/administration/#uploaded-file-path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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