permalinks – How to use ‘blogs.dir’ as media upload instead of ‘uploads’ directory in WordPress multisite setup

Question

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', "https://wordpress.stackexchange.com/" );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

define('ADMIN_COOKIE_PATH', "https://wordpress.stackexchange.com/"); // 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?

0
AnupRaj 2 weeks 2023-01-14T04:41:29-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse