[Wordpress] I want to eliminate the redirect loop

After installing Wordpress on Xserver, SSL was done.
Until then, login was successful, but a redirect loop occurred.

Error message

Specific symptoms include
If i access, enter your user name and e-mail address, and press the login button, you will be redirected to the following URL without the password being incorrect.
If i enter your username and email address on this page and press the login button, you will be redirected to the same screen. Therefore, you cannot log in to the management screen.
*ERR_TOO_MANY_REDIRECTSis not displayed.

There are many people who suffer from the same symptoms.

Specifically, the following measures were implemented.

  • Check that the username and password are correct
  • Delete cookies
  • Access from wp-login.php
  • Check that the database is not over capacity
  • Change site URL settings from phpmyAdmin
  • Stop plug-in (rename folder)
  • Stop theme (rename folder)
  • Add two lines to wp-config.php
  • Change rewrite conditions of .htaccess
Reference source code


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond% {HTTP: X-Forwarded-Proto}! = Https
RewriteRule ^ /? (. *) Https: //% {HTTP_HOST}/$1 [R, L]
RewriteBase/wp /
RewriteRule ^ index \ .php $-[L]
RewriteRule. /Wp/index.php [L]
# END WordPress


<? php
$_SERVER ['HTTPS'] = 'on';
$_ENV ['HTTPS'] = 'on';
define ('DB_NAME', '***');
/ ** MySQL database username * /
define ('DB_USER', '***');
/ ** MySQL database password * /
define ('DB_PASSWORD', '***');
/ ** MySQL hostname * /
define ('DB_HOST', '***');
/ ** Database character set when creating database tables * /
define ('DB_CHARSET', '***');
/ ** Database collation (almost no need to change) * /
define ('DB_COLLATE', '');
define ('WP_DEBUG', false);
define ('FORCE_SSL_LOGIN', true);
define ('FORCE_SSL_ADMIN', true);
_PROTO '] ==' https') {
       $_SERVER ['HTTPS'] = 'on';
/ ** Omitted such as define ('AUTH_KEY', '***');for confidential information * /
/ * That's all you need to edit! Enjoy publishing in WordPress. * /
/ ** Absolute path to the WordPress directory.
if (! defined ('ABSPATH'))
    define ('ABSPATH', dirname (__ FILE__). '/');
/ ** Sets up WordPress vars and included files. * /
require_once (ABSPATH. 'wp-settings.php');
Supplemental information (FW/tool version etc.)

The last two articles were based on the following articles.

Are there any other measures? I would appreciate your help.

  • Answer # 1

    Self-solved. The cause was written in the error log.

    Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_usermeta` ...

    Apparently, the cause is that the umeta_id in the wp_usermeta table was not set to auto increment.

    When using SSL, I used Search-Replace-DB-master, but I think it was necessary to set the Primary Key and set it to auto increment.

    Check for errors first

    Attach an error log when asking a question

    I will be careful.

  • Answer # 2

    What about adding the following to wp-config.php?

    define ('FORCE_SSL_ADMIN', true);