Wordpress-/wp-admin/在登录时重定向到/wp-login.php


Wordpress - /wp-admin/ redirecting to /wp-login.php, when logged-in

登录wp-admin时,将通过302重定向到wp-login.php


有两种行为:

1( 用户名/密码正确。302重定向到/wp-admin/,然后302重定向到wp-login.php

2( 输入的用户名/密码错误,无法重定向。200响应显示"错误:用户名或密码不正确。"。


Wordpress配置(我已经用"testdomain.com"替换了真实域(:

$_SERVER['HTTPS']='on';
define( 'FORCE_SSL_LOGIN', false );
define( 'FORCE_SSL_ADMIN', false );
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
//$currenthost = "https://".$_SERVER['HTTP_HOST'];
$currenthost = "https://exampledomain.com";
$currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
$currentpath = preg_replace('/'/wp.+/','',$currentpath);
define('WP_HOME',$currenthost.$currentpath);
define('WP_SITEURL',$currenthost.$currentpath);
define('WP_CONTENT_URL', $currenthost.$currentpath.'/wp-content');
define('WP_PLUGIN_URL', $currenthost.$currentpath.'/wp-content/plugins');
define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath );
define('ADMIN_COOKIE_PATH', './');
define('WP_BASE', $currenthost.$currentpath);
define('FS_METHOD', 'direct');
define('FS_CHMOD_DIR', (0705 & ~ umask()));
define('FS_CHMOD_FILE', (0604 & ~ umask()));

有什么想法吗?

如果你确定你的登录凭据是正确的,你可以使用"wp_authenticate"挂钩,如下所示:

add_action('wp_authenticate', 'mysite_check_already_logged_in');
function mysite_check_already_logged_in() {
    if (is_user_logged_in()) {
        wp_redirect(site_url('wp-admin'));
    }
}