简体   繁体   English

WordPress-/ wp-admin /登录后重定向到/wp-login.php

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

When logged-in wp-admin is redirecting to wp-login.php via 302. 登录后, wp-admin将通过302重定向到wp-login.php


There are 2 behaviours: 有两种行为:

1) Username/password correct. 1)用户名/密码正确。 302 redirect to /wp-admin/ followed by a 302 redirect to /wp-login.php 302重定向到/ wp-admin /,然后是302重定向到/wp-login.php

2) Username/Password entered is wrong, no redirect. 2)输入的用户名/密码错误,没有重定向。 200 response with "ERROR: Incorrect username or password." 200响应,内容为“错误:用户名或密码错误”。 displayed. 显示。


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

Any ideas? 有任何想法吗?

If you are sure that your login credentials are correct, you can make use of the "wp_authenticate" hook as follows: 如果您确定登录凭据正确无误,则可以使用“ 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'));
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM