1

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
  • Chances are this isn't your problem because it's pretty rare but I figured I should mention it, maybe it will help someone at some point: I've seen this kind of behavior some time ago and tracked it to be caused by the fact that the database server did not have enough space.
    – mishu
    Jul 3, 2015 at 12:49

1 Answer 1

1

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'));
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.