WordPress后台登录出现“重定向的次数过多”的解决方法

2024年1月7日 405点热度 0人点赞 0条评论

WordPress网站开启https后,登录管理后台的时候出现“重定向的次数过多”导致网站无法访问。

通过此工具分析重定向消息如下:

Problems found:

  • Too many redirects. Please try to reduce your number of redirects for https://blog.yanghong.dev/wp-admin. Actually you use 19 Redirects. Ideally you should not use more than 3 Redirects in a redirect chain. More than 3 redirections will produce unnecessary load on your server and reduces speed, which ends up in bad user experience.
  • You use 301 and 302 redirect at the same time. This might be confusing for search engine. Generally, please do not use 301 and 302 redirects at the same time.
  • You use a 302 redirect. This means, that the actually content is temporary not reachable and will come back soon. To use a 302 redirection for generally moved pages is a bad idea. Search engine bot might not follow it or handle it as temporary. For SEO this is also a bad idea, because no link juice will be transferred to the linked page.

解决方法:

登录网站FTP或者网站主机的文件管理,找到网站根目录下的 wp-config.php 文件,添加以下代码,即可解决此问题。

$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

予人玫瑰,手有余香。如果您觉得本文对您有帮助,请点赞或打赏。

文章评论

您需要 登录 之后才可以评论