title: How to fix the HTTPS Wordpress wp-admin redirect loop
body: <p>I know there is a lot of questions like this but none has given me an answer that resolved my problem with my WordPress wp-admin/ page, the browser throws an ERR_TOO_MANY_REDIRECTS error, I have disabled all plugins, cleared my cache and cookies, edited my wp-config.php file but still nothing.</p>
  
  <p>my apache config:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName example.com
      ServerAlias www.example.com
      Redirect permanent / "https://example.com/"
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <pre><code>&lt;IfModule mod_ssl.c&gt;
      &lt;VirtualHost *:443&gt;
  
          ServerName example.com
          ServerAlias www.example.com
  
          DocumentRoot /var/www
  
          Include /etc/letsencrypt/options-ssl-apache.conf
          SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
          SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          &lt;Directory /var/www&gt;
              AllowOverride None
              Order Allow,Deny
              Allow from All
  
              DirectoryIndex index.php
  
              &lt;IfModule mod_rewrite.c&gt;
                  RewriteEngine On
                  RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
                  RewriteRule ^(.*) - [E=BASE:%1]
                  RewriteCond %{HTTP:Authorization} .
                  RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  
                  RewriteCond %{ENV:REDIRECT_STATUS} ^$
                  RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
  
                  RewriteCond %{REQUEST_FILENAME} -f
                  RewriteRule ^ - [L]
  
                  RewriteRule ^ %{ENV:BASE}/index.php [L]
              &lt;/IfModule&gt;
  
              &lt;IfModule !mod_rewrite.c&gt;
                  &lt;IfModule mod_alias.c&gt;
                      RedirectMatch 307 ^/$ /index.php
                  &lt;/IfModule&gt;
              &lt;/IfModule&gt;
  
          &lt;/Directory&gt;
  
      &lt;/VirtualHost&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>my wp-config.php</p>
  
  <pre class="lang-php prettyprint-override"><code>define('WP_HOME','https://example.com');
  define('WP_SITEURL','https://example.com');
  
  /** SSL */
  define('FORCE_SSL_ADMIN', true);
  
  if((empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') &amp;&amp; $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS'] = 'on';
  </code></pre>
  
  <p>my $_SERVER variable:</p>
  
  <pre class="lang-php prettyprint-override"><code>
  Array
  (
      [SERVER_SOFTWARE] =&gt; Apache/2.4.29 (Ubuntu)
      [REQUEST_URI] =&gt; /wp-admin/?test=1
      [REDIRECT_HTTPS] =&gt; on
      [REDIRECT_SSL_TLS_SNI] =&gt; example.com
      [REDIRECT_STATUS] =&gt; 200
      [HTTPS] =&gt; on
      [SSL_TLS_SNI] =&gt; example.com
      [HTTP_HOST] =&gt; example.com
      [HTTP_CONNECTION] =&gt; keep-alive
      [HTTP_UPGRADE_INSECURE_REQUESTS] =&gt; 1
      [HTTP_USER_AGENT] =&gt; Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
      [HTTP_DNT] =&gt; 1
      [HTTP_ACCEPT] =&gt; text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
      [HTTP_ACCEPT_ENCODING] =&gt; gzip, deflate, br
      [HTTP_ACCEPT_LANGUAGE] =&gt; es-ES,es;q=0.9,en;q=0.8,pt;q=0.7
      [HTTP_COOKIE] =&gt; PHPSESSID=84c3jbfdtbmcl4jnibgobm3666
      [PATH] =&gt; /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      [SERVER_SIGNATURE] =&gt; 
  Apache/2.4.29 (Ubuntu) Server at example.com Port 443
  
  
      [SERVER_NAME] =&gt; example.com
      [SERVER_ADDR] =&gt; xxx.xxx.xxx.xxx
      [SERVER_PORT] =&gt; 443
      [REMOTE_ADDR] =&gt; xxx.xxx.xxx.xxx
      [DOCUMENT_ROOT] =&gt; /var/www
      [REQUEST_SCHEME] =&gt; https
      [CONTEXT_PREFIX] =&gt; 
      [CONTEXT_DOCUMENT_ROOT] =&gt; /var/www
      [SERVER_ADMIN] =&gt; [no address given]
      [SCRIPT_FILENAME] =&gt; /var/www/index.php
      [REMOTE_PORT] =&gt; 52242
      [REDIRECT_URL] =&gt; /wp-admin/
      [REDIRECT_QUERY_STRING] =&gt; test=1
      [GATEWAY_INTERFACE] =&gt; CGI/1.1
      [SERVER_PROTOCOL] =&gt; HTTP/1.1
      [REQUEST_METHOD] =&gt; GET
      [QUERY_STRING] =&gt; test=1
      [SCRIPT_NAME] =&gt; /index.php
      [PHP_SELF] =&gt; /index.php
      [REQUEST_TIME_FLOAT] =&gt; 1550424580.519
      [REQUEST_TIME] =&gt; 1550424580
  )
  
  </code></pre>