WP-Admin在带有子目录的WordPress多站点上无法正常工作

时间:2016-11-21 作者:schescher

我最近在我的域名上安装了Wordpress多站点博客。

除了子网站的wp admin外,一切正常:

我可以访问子网站的wp admin,但css没有加载,当我尝试单击导航链接时,会出现wordpress“File not found”错误。

这是因为它链接到域等。com/subsite/wp admin/post new。php-它不存在。(domain.com/wp-admin/post-new.php存在)

我还认为css不起作用,域。com/子网站/wp管理/加载样式。phpand加载脚本。找不到php

以下是我在访问/子网站/wp管理员时在chrome开发者工具中遇到的一个错误

enter image description here

我正在使用标准。到处粘贴的htaccess:

    # 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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress
我想错误一定在这里,对吗?

以下是wp配置-以防万一:

<?php

 define(\'WP_ALLOW_MULTISITE\', true);

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'XXX\');

/** MySQL database username */
define(\'DB_USER\', \'XXX\');

/** MySQL database password */
define(\'DB_PASSWORD\', \'XXX\');

/** MySQL hostname */
define(\'DB_HOST\', \'XXX\');

/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'utf8\');

/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define(\'AUTH_KEY\', XXX);
define(\'SECURE_AUTH_KEY\',XXX);
define(\'LOGGED_IN_KEY\',XXX);
define(\'NONCE_KEY\',        XXX);
define(\'AUTH_SALT\',        XXX);
define(\'SECURE_AUTH_SALT\', XXX);
define(\'LOGGED_IN_SALT\',   XXX);
define(\'NONCE_SALT\',       XXX);
/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = \'XXX\';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define(\'WP_DEBUG\', false);


define(\'MULTISITE\', true);
define(\'SUBDOMAIN_INSTALL\', false);
define(\'DOMAIN_CURRENT_SITE\', \'mydomain.com\');
define(\'PATH_CURRENT_SITE\', \'/\');
define(\'SITE_ID_CURRENT_SITE\', 1);
define(\'BLOG_ID_CURRENT_SITE\', 1);




/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');

define( \'WP_ALLOW_MULTISITE\', true );

define (\'FS_METHOD\', \'direct\');
?>

1 个回复
SO网友:Pat J

如果从版本3.0到3.4.2开始安装WordPress Multisite,则.htaccess 文件内容。

然而,如果您是从一个更新的版本(3.5或更高版本)开始的,我假设您是这样做的,如果您最近刚刚安装了WordPress Multisite.htaccess 文件应如下所示:

RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]
我假设您正在子文件夹模式下使用Multisite,因为在您的问题中,您的URL是example.com/site/wp-admin. (Edit: 此外,我刚刚注意到,根据您的帖子,它肯定是子文件夹wp-config.php 文件。)

请参见Codex page on .htaccess 有关详细信息。

相关推荐

WordPress网站损坏,链接失效,无法访问wp-admin页面

我刚刚收到一个坏掉的Wordpress网站,我现在负责管理这个网站。编辑:自从发布这篇文章以来,我对自己的问题有了一些新的发现。当尝试访问Wordpress管理页面(通过单击登录仪表板的链接)时,我得到一个404未找到页面。此404错误页面与所托管网站上的所有其他页面具有相同的品牌(背景和样式)。我猜我的链接断了。网站上的身份验证页面不起作用,我无法访问前面所述的管理门户。我有权访问根目录和wp content文件夹。该页面由wordpress托管,我通过启用sftp访问root。我还可以访问phpMyA