最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

htaccess - Getting file errors in a Wordpress Multisite ADMIN

programmeradmin2浏览0评论

This is for a multisite that has 3 levels of organization: main site - regions (subsites) and locations (sub-subsites). So you would be able to visit and administrate these urls:

domain --> main site domain/region --> sub site domain/region/location --> sub-sub site

Both front and back end are getting loading errors in the Inspect Console because the path to the files in "wp-includes" and "wp-admin" are wrong.

I have sunrise.php activated.

These are the lines I added to wp-config.php:

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'MY-DOMAIN'); // <- my real domain there
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

define("WP_CONTENT_URL", "/wp-content");

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

// Activate sunrise script
  define('SUNRISE', TRUE);
// define('WP_ALLOW_REPAIR', true);

This is my .htaccess file:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)+(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
# RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteRule . index.php [L]
# END WordPress

This is my sunrise.php file

id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1); $current_site->domain = $domain = DOMAIN_CURRENT_SITE; $current_site->path = $path = PATH_CURRENT_SITE; if( defined( 'BLOGID_CURRENT_SITE' ) ) $current_site->blog_id = BLOGID_CURRENT_SITE; $url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); $patharray = (array) explode( '/', trim( $url, '/' )); $blogsearch = ''; if( count( $patharray )){ foreach( $patharray as $pathpart ){ $pathsearch .= '/'. $pathpart; $blogsearch .= $wpdb->prepare(" OR (domain = %s AND path = %s) ", $domain, $pathsearch .'/' ); } } $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '/'", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1'); $blog_id = $current_blog->blog_id; $public = $current_blog->public; $site_id = $current_blog->site_id; $current_site = pu_get_current_site_name( $current_site ); } function pu_get_current_site_name( $current_site ) { global $wpdb; $current_site->site_name = wp_cache_get( $current_site->id . ':current_site_name', "site-options" ); if ( !$current_site->site_name ) { $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) ); if( $current_site->site_name == null ) $current_site->site_name = ucfirst( $current_site->domain ); wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options'); } return $current_site; } ?>
发布评论

评论列表(0)

  1. 暂无评论