Wordpress - /wp-admin/ redirecting to /wp-login.ph

2019-05-30 03:20发布

When logged-in wp-admin is redirecting to wp-login.php via 302.


There are 2 behaviours:

1) Username/password correct. 302 redirect to /wp-admin/ followed by a 302 redirect to /wp-login.php

2) Username/Password entered is wrong, no redirect. 200 response with "ERROR: Incorrect username or password." displayed.


Wordpress configuration (I've replaced the real domain with "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()));

Any ideas?

1条回答
叼着烟拽天下
2楼-- · 2019-05-30 03:41

If you are sure that your login credentials are correct, you can make use of the "wp_authenticate" hook as follows:

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'));
    }
}
查看更多
登录 后发表回答