移动服务器后Wordpress管理员登录cookie阻止了错误 [英] Wordpress admin login cookies blocked error after moving servers

查看:247
本文介绍了移动服务器后Wordpress管理员登录cookie阻止了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:在olddomain.com上有一个可用的Wordpress 3.7网站.

Background: had a working Wordpress 3.7 site at olddomain.com.

我已将其成功移动到newdomain.com,并在此过程中将其添加到wp-config:

I moved it to newdomain.com successfully, and in the process added this to wp-config:

define('WP_HOME','http://newdomain.com');
define('WP_SITEURL','http://newdomain.com');

现在,当我尝试从newdomain.com/wp-admin登录时,出现跨浏览器错误(尽管启用了cookie并清除了现有的cookie):

Now when I attempt to login from newdomain.com/wp-admin I'm getting the cross-browser error (despite having cookies enabled and clearing existing cookies):

ERROR: Cookies are blocked or not supported by // your browser. 
You must enable cookies to use WordPress.

我尝试进入wp-login.php并注释了以下几行(744-747)以停止有条件的testcookie检查

I tried going into wp-login.php and commenting out the following lines (744-747) to stop the conditional testcookie check

    // If cookies are disabled we can't log in even with a valid user+pass
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
    $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by // your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
else
    $user = wp_signon('', $secure_cookie);

但是这样做会使我陷入重定向循环中,回到管理页面:

but doing that leaves me stuck in a redirect loop back to the admin page:

http://myapp.com/wp-login.php?redirect_to=http%3A%2F%2Fmyapp.com%2Fwp-admin%2F&reauth=1

我需要更改(或不设置)网站URL吗?还是有另一种可能的方法来解决此问题?谢谢

Do I need to change (or not set) the site URL? or is there another potential way to troubleshoot this? thanks

推荐答案

已经迁移了数百个WP网站,以下是一些想法:

Having migrated hundreds of WP sites, here's a few thoughts :

如果迁移数据库:检查数据库选项表(可能是wp_options)列"option_name",其值"siteurl"和"home"具有与您的站点正确的"option_value". "siteurl"非常大.

If migrating the DB : Check the database options table (probably wp_options) column "option_name" that values "siteurl" and "home" have the correct "option_value" for your site. "siteurl" is huge.

我可以证明选项表调整是将数据库迁移到WP中新域所需的最低要求. (不会导致重定向,仍然会出现问题)

I can testify that the options table tweak is the bare minimum required to migrate a DB to a new domain in WP. (will not cause redirection, will still have issues)

WP查找了这些数据库选项以将站点序列化为域,我很确定定义在堆栈中较低并且没有帮助.将wp-admin活动视为松散地耦合到前端.您可以破坏前面的所有内容(完成操作),而管理员仍然可以使用.

WP looks up these DB options to serialize the site to domain and I am pretty sure the defines are lower in the stack and of no help. Consider the wp-admin activities as loosely coupled to the front. You can break everything (done it) in the front and the admin will still function.

还-该站点是否/可以正常安装/不进行迁移或调整?

Also - did/does the site work with generic install/no migration or tweaks?

如上所述-.htaccess(丢失或配置错误)将导致您的错误.关于.htaccess文件,如果使用的话,这是一个dot.file,许多操作系统将忽略"或使其不可见",因此复制/粘贴或FTP应用程序或类似应用程序可能不携带.htaccess

As mentioned - .htaccess (missing or misconfigured) will cause your error. Regarding the .htaccess file, if used, this is a dot.file and many operating systems will "ignore" or "make invisible" so a copy/paste or FTP application or similar may not carry the .htaccess

(对此非常确定)如果您移动数据库并使用了漂亮的url,却错过了可能需要修复的.htaccess文件.我刚刚在沙盒安装上进行了本地测试,当列option_value中留空时,表wp_option列"option_name"值"permalink_structure"将返回?p = 1(非永久链接)状态,并且.htaccess大部分会被绕过.

(pretty sure on this) If you moved the DB and used pretty urls, and missed the .htaccess that could be all you need to fix. I just tested locally on a sandbox install and the table wp_option column "option_name" value "permalink_structure" when left blank in column option_value will return to ?p=1 (non-permalink) status and .htaccess will be mostly bypassed.

这篇关于移动服务器后Wordpress管理员登录cookie阻止了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆