今天我尝试将Wordpress更新到最新版本(3.5.1)。完成此操作后,我无法再打开wp-admin/index.php
。它给了我一个404错误。我已经查看了index.php
文件,当调用函数auth_redirect()
时,它会中断。这是该功能的代码:
function auth_redirect() {
// Checks if a user is logged in, if not redirects them to the login page
$secure = ( is_ssl() || force_ssl_admin() );
$secure = apply_filters('secure_auth_redirect', $secure);
// If https is required and request is http, redirect
if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
exit();
} else {
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
exit();
}
}
if ( is_user_admin() )
$scheme = 'logged_in';
else
$scheme = apply_filters( 'auth_redirect_scheme', '' );
if ( $user_id = wp_validate_auth_cookie( '', $scheme) ) {
do_action('auth_redirect', $user_id);
// If the user wants ssl but the session is not ssl, redirect.
if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
exit();
} else {
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
exit();
}
}
return; // The cookie is good so we're done
}
// The cookie is no good so force login
nocache_headers();
$redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$login_url = wp_login_url($redirect, true);
wp_redirect($login_url);
exit();
}
然而,我找不到它中断的具体部分,因为它没有给我错误消息,它只显示了一个404页面,在Firefox中它说它没有正确重定向。
有人能帮我一下吗?
谢谢!
一些附加信息:
我找到了它断裂的地方,它是:
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
呼应$_SERVER['HTTP_HOST']
和$_SERVER['REQUEST_URI']
给了我预期的结果(www.domain.com/blog)。但是它不起作用:(
我过去也遇到过类似的问题。但它通常涉及到一个新的插件安装。。。几件事:
- 尝试增加可用的RAM。WP在过去给我带来了类似的麻烦,这与RAM有关。您应该能够增加.htaccess文件中的RAM
- 这是生产系统吗?如果没有,也许记下所有插件,删除它们,尝试访问系统。如果这是有效的,那么你就知道这个问题是基于插件的,而不是WP本身。然后,您可以一个接一个地系统地添加插件,并确定是哪个插件导致了问题