WP Multisite fix for WP install in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Our Wordpress is located in https://our-site.com/wordpress | |
Here's the relevant part of our wp-config.php | |
define('MULTISITE', true); | |
define('SUBDOMAIN_INSTALL', true); | |
define('DOMAIN_CURRENT_SITE', 'our-site.com'); | |
define('PATH_CURRENT_SITE', '/'); | |
define('SITE_ID_CURRENT_SITE', 1); | |
define('BLOG_ID_CURRENT_SITE', 1); | |
However the "Lost your password" URL on http://our-site.com/wordpress/login.php it then set to: https://our-site.com/wp-login.php?action=lostpassword - so the /wordpress part is missing. | |
Put this into wp-content/mu-plugins | |
*/ | |
define('FV_PATH_CURRENT_SITE', '/site/'); | |
add_filter( 'network_site_url', 'fv_network_site_url' ); | |
function fv_network_site_url( $url ) { | |
$current_site = get_current_site(); | |
if( strcmp($current_site->domain. $current_site->path, $current_site->domain.FV_PATH_CURRENT_SITE) ) { | |
$url = str_replace( $current_site->domain. $current_site->path, $current_site->domain.FV_PATH_CURRENT_SITE, $url ); | |
} | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment