This is not a guide (yet?). These are just notes for personal reference which may be expanded upon later.
Site owners/developers/administrators may find useful hints below, but please do not get mad at me if you break your site.
Methods were initially tested on a multisite-with-subdirectories installation, but are generally applicable to single and subdomain installations as well.
standard installation
familiar structure, e.g.
├── wp-config.php
└── wp-content/
└── plugins/
nginx (subdirectory multisite)
if (!-e $request_filename) {
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
rename wp-content
change structure, e.g.
├── wp-config.php
└── content/
├── plugins/
wp-config.php
define( 'WP_CONTENT_DIR', ABSPATH . 'content' );
define( 'WP_CONTENT_URL', '/content' );
rename plugins (style 1)
Keep plugins directory inside content
├── wp-config.php
└── content/
└── modules/
wp-config.php
define( 'WP_CONTENT_DIR', ABSPATH . 'content' );
define( 'WP_CONTENT_URL', '/content' );
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/modules' );
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/modules' );
Note, WP_CONTENT_*
values must be defined as well, even if you don’t wish to change that location
rename plugins (style 2)
Move plugins directory outside the content directory
├── wp-config.php
├── wp-content/
└── modules/
wp-config.php
define( 'WP_PLUGIN_DIR', ABSPATH . 'modules' );
define( 'WP_PLUGIN_URL', '/modules' );
rename mu-plugins
Same procedure as plugins, but use the constants WPMU_PLUGIN_DIR
and WPMU_PLUGIN_URL
rename themes
Themes follow a different pattern. More info soon, maybe.
relocate core
├── wp-config.php
├── wp-content/
└── wproot/
├── wp-admin/
└── wp-includes/
nginx
location /wproot/wp- {}
if (!-e $request_filename) {
rewrite ^/wproot(/[^/]+)?(/wp-.*) /wproot$2 last;
rewrite ^/wproot(/[^/]+)?(/.*\.php) /wproot$2 last;
}
location / {
try_files $uri /wproot$uri/ /wproot/index.php?$args;
}
wp-config.php
define( 'PATH_CURRENT_SITE', '/wproot/' );
define( 'SITECOOKIEPATH', '/' );
define( 'COOKIEPATH', '/' );
plugin
add_filter( 'redirect_network_admin_request', '__return_false' );
database
wp_options
: append wproot
to siteurl
Subdirectory
Subsites will be located at example.com/wproot/subsite
.
Subdomain
Subsites will be located at subsite.example.com/wproot
. The “nub” can be removed by editing two database fields:
wp_blogs
: pathwp_#_options
: home
These can be edited through the UI by first changing the Site Address (URL) field on the Edit Site > Info screen (e.g. wp-admin/network/site-info.php?id=#
). Second, go to Edit Site > Settings (wp-admin/network/site-settings.php?id=#
) and restore the “nub” to the Siteurl field