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

时间:2015-07-03 12:38:54

标签: php wordpress apache .htaccess redirect

登录时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()));

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

如果您确定您的登录凭据正确无误,则可以使用" 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'));
    }
}