This plugin allow to build development environment without copy data from uploads folder. Manage an failback with PHP and production assets.
Define constants :
define( 'UPLOADS_STRUCTURE_NAME', 'wp-content/uploads, wp-content/blogs.dir' );
define( 'PROD_UPLOADS_URL', 'http://myproddomain' );
You need to add the following rule before this line wp-(content|admin|includes).*)
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-content/uploads.*) $1 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
If your Multisite installation is an old verison with the blog.dir folder, you have to use this rule
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) $2 [L]
It is likely that the NGINX configuration looks like this:
location ~* ^.+\.(ogg|ogv|svg|svgz|mp4|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|$
# access_log off;
# log_not_found off;
expires max;
}
With this configuration, there is no possible failback with WordPress, you must add the following statement in the condition:
try_files $uri $uri/ /index.php?$args;
Full example :
location ~* ^.+\.(ogg|ogv|svg|svgz|mp4|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|$
# access_log off;
# log_not_found off;
expires max;
try_files $uri $uri/ /index.php?$args;
}
And in the wp-config.php
define( 'UPLOADS_STRUCTURE_NAME', 'wp-content/blogs.dir' );
Optionally you can add
define( 'PROD_SSL_VERIFY', false );// default is true
- 13 May 2019
- Refactoring mimes types check (add SVG support)
- Improve readme (nginx part)
- 18 December 2018
- Minor code refactoring (phpcs)
- Add filter prod_images/remote_get_url
- 14 March 2018
- Add two HTTP headers for allow easier debugging
- 12 March 2018
- Add constant PROD_SSL_VERIFY and filter prod_images/remote_get_args
- 08 January 2018
- Allow multiples values for UPLOADS_STRUCTURE_NAME
- 08 September 2016
- fix fatal error on single site due to is_subdomain_install() function
- 23 August 2016
- fix loading of local images
- 28 July 2016
- fix cached image withe WP Rocket
- 06 April 2016
- fix for wp_debug
- 18 Feb 2016
- initial