I’m just looking into roots and enabled the option to change the upload directory to “media” but this poses a small problem. I’ve organised my project structure (as shown in the Composer blogpost) to have all WP core files in the “wp” directory and moved the “wp-content” directory outside of the “wp” directory. Any plugins and themes are now located outside of the “wp” directory.
Problem is that the “media” directory is now located inside the “wp” directory instead of alongside the “wp” and “wp-content” directories.
The relevant part of the configuration (I think) is:
/* Run WordPress from a subdirectory */
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/roots/wp');
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] . '/roots');
/* Separate the wp-content directory from the WordPress install */
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/roots/wp-content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/roots/wp-content');
Thanks for this. I haven’t started using Composer quite yet. However I had a related question as to how is the rewrite for changing to the /media/ directory handled? Is this added to the .htaccess folder?
I’ve been having a few issues on a number of sites where I get loads of 404s because the site thinks the image files are in the wrong directory. I’ve got confused as to whether they should be in /media/ or /assets/ in the root directory (i.e. not in the theme directory)
The change of upload folder is not handled by a rewrite rule but rather internally by WordPress.
You can use the following rules (that is, I use these rules): things that are needed to display your site properly should be in the assets folder, anything content related should be in the media folder.
@swalkinshaw so, when using composer, my media folder ends up /wp/media when I activate roots. What steps need to happen to get it to be in a different location?
I’d make sure it actually ran by checking the updated options in the database. Or just put some debugging code in that if statement to make sure it executes. That would be the first thing to confirm.
Ok, so here is the issue. I use port numbers for my development sites, so _SERVER['SERVER_NAME'] resolves to the server name only (i.e localhost:8080 would be localhost). It never modified the paths.
just wondering if this is still the best option to set the folder structure for multisite. Facing the same issue still in 2018 that the UPLOADSconstant is relative to ABSPATH: