title: Error TOO MANY REDIRECTS debbuged
body: <p>I'm spending a few hours trying to solve this <code>ERR_TOO_MANY_REDIRECTS</code> without success.</p>
  
  <p>It happens when I access my website URL without being logged in. So if I do not have a session started I will be redirect to -> mywebsite.com/site/login or just /login</p>
  
  <p>The PHP code that makes that is below:</p>
  
  <pre><code>if ( isset($_GET['p2k_url']) &amp;&amp; $_GET['p2k_url'] ) {
  
          if ( strstr($_GET['p2k_url'], '/') ) {
  
              $url = explode('/', $_GET['p2k_url']);
  
          } else {
              $url[0] = $_GET['p2k_url'];
          }
  
          if ( !isset($url[1]) || !$url[1] ) {
              $url[1] = 'index';
          }
      }
  
      if ( $url[0] != 'login' &amp;&amp; !$__usuCod ) {
          header('Location: /site/login.php');
          die();
      }
  
      if ( file_exists(SITE_DIR.DS.'_'.$url[0].DS.$url[1].'.php') ) {
  
          include SITE_DIR.DS.'_'.$url[0].DS.$url[1].'.php';
  
      } else {
  
          if ( file_exists(SITE_DIR.DS.'_'.$url[0].DS.'no404.php') ) {
              include SITE_DIR.DS.'_'.$url[0].DS.'index.php';
          } else {
              include SITE_DIR.DS.'_404'.DS.'index.php';
          }
      }
  </code></pre>
  
  <p>Right here: <code>if ( $url[0] != 'login' &amp;&amp; !$__usuCod ) {</code></p>
  
  <p>My login.php is just a simple html page with form. Nothing there to worry about.</p>
  
  <p>Although my main .htaccess is below and I think it might have something there:</p>
  
  <p>Options -indexes</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine on
      RewriteRule ^(.*)$ index.php?p2k_url=$1 [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>In order to debug and find the error, when I run tail -f access_log I get just simple access requests:</p>
  
  <pre><code>127.0.0.1 - - [01/Nov/2016:11:16:28 -0200] "GET /site/login.php HTTP/1.1" 302 -
  </code></pre>
  
  <p>Nothing coming on error_log tough.</p>
  
  <p>Doing reseraches I see that is a very comum problem on WP - which is not the case here. Any ideas?</p>
  
  <p>Thanks</p>