多站点上的WordPress 4.7.2更新导致wp-admin重定向循环

时间:2017-02-10 17:55:03

标签: wordpress .htaccess multisite redirect-loop wp-admin

我有一个使用子目录设置运行多站点的网站。我刚刚尝试将我的站点更新到4.7.2并且更新完成并且安装期间没有发生错误,但是在安装完成后我被重定向到/wp-admin/network/about.php?updated返回404页。那么我尝试回到/ wp-admin /,我得到一个重定向循环错误。

我查看了至少40篇关于WordPress多站点wp-admin重定向循环问题的文章,论坛和网站。我已经尝试了一些我可能找到的解决这个问题的方法,但没有任何效果。主站点工作得很好,但是wp-admin是完全无法访问的。

以下是我到目前为止所尝试的内容:

  1. 我尝试多次清除缓存和Cookie,并且该网站没有使用任何缓存插件
  2. 我将我的插件文件夹重命名为plugins.deactivate 为了更加彻底,我还将wp_options表中的active_plugins字段更新为:0:{}
  3. 我尝试从我的wp-config.php文件中删除多站点定义,但是当它没有效果时我将它们放回去
  4. 我确认我的.htaccess文件与此处列出的3.5+多站点文件匹配 - https://codex.wordpress.org/Multisite_Network_Administration#.htaccess_and_Mod_Rewrite
  5. 我也尝试将它切换到旧版本,以防万一,但没有做任何事情,所以我把它切换回来。
  6. 我发现一个论坛说他们通过在/wp-admin/network/admin.php底部注释掉一个重定向来解决这个问题,所以我尝试了但是没有做任何事情,所以我将它取消注释回正常。
  7. 我发现另一个论坛说你需要在wp-config.php中定义cookie路径。所以我试过把下面的代码添加到我的wp-config.php中,但它也没有用,所以我把它删除了。
  8. 我试过的Cookie路径代码:

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

    这是我的.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]
    

    这是我的wp-config.php文件:

    <?php
    /**
     * The base configuration for WordPress
     *
     * The wp-config.php creation script uses this file during the
     * installation. You don't have to use the web site, you can
     * copy this file to "wp-config.php" and fill in the values.
     *
     * This file contains the following configurations:
     *
     * * MySQL settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/Editing_wp-config.php
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'DBNAME');
    
    /** MySQL database username */
    define('DB_USER', 'DBUNAME');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'DBPASS');
    
    /** MySQL hostname */
    define('DB_HOST', 'DBHOST');
    
    /** 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',         'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_KEY',  'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_KEY',    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_KEY',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('AUTH_SALT',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_SALT', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_SALT',   'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_SALT',       'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    
    /**
     * Other customizations.
     */
    define('FS_METHOD','direct');define('FS_CHMOD_DIR',0777);define('FS_CHMOD_FILE',0666);
    define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/uploads');
    
    /**
     * Turn off automatic updates since these are managed upstream.
     */
    define('AUTOMATIC_UPDATER_DISABLED', true);
    
    
    /**#@-*/
    
    /**
     * 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  = 'XXXXXX';
    
    /**
     * 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('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']);
    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');
    

1 个答案:

答案 0 :(得分:0)

我发现了这个问题!在尝试将全新的WordPress副本安装到新的子域并立即获得太多重定向错误后,我知道问题必须在服务器级别。

我在cPanel中检查了我的错误日志,发现每次我尝试访问wp-admin中的任何内容时都会抛出错误,因为这些文件是由具有0664权限的组写入的。

我将wp-admin中的所有文件和wp-includes更改为0644权限和bam!现在一切正常!

如果您有太多重定向问题,请检查错误日志。我不确定这只是我的服务器,还是WP在最近的更新中增加了额外的安全级别,但我很高兴它现在已经修好了!