title: CodeIgniter Controllers Loading Twice When Using Parameters in the URL
body: <p>I'm having an issue where my CodeIgniter controllers are being called twice. It only seems to occur when I am using parameters in the uri (/newsletter/confirm/a1938cas893vf9384f0384f0943). If I remove the parameter from my function it only loads the controller once. I also noticed that with the parameter in the url, if I refresh the page it only loads once. So it seems that it is loading twice only when a new page is called.</p>
  
  <p>For example navigating to /newsletter/confirm/a123 for the very first time will result in it loading twice. But if you were to refresh /newsletter/confirm/a123 it will only load once. I've completed commented out calls to my view to eliminate an issue with the view causing it.</p>
  
  <p>Does this sound like a cache issue, or something in my .htaccess file? Thanks for any suggestions.</p>
  
  <p>Relevant controller:</p>
  
  <pre><code>&lt;?php
  error_reporting(-1); 
    ini_set('display_errors',1);
  class Test extends CI_Controller {
  
      function __construct() {
      parent::__construct();
          log_message('debug', 'MyController initialised'); 
      }
  
      function confirm($code)
      {
          $this-&gt;load-&gt;helper(array('form'));
  
          //$code = "6e930fe882c3b15712158812769dbcb636f96b8c";
          $result = $this-&gt;db-&gt;get_where('newsletter_members', array('nm_confirmation_code' =&gt; $code, 'nm_subscribed' =&gt; 0));
  
          if ($result-&gt;num_rows == 0)
          {
              $newsletter_message['newsletter_message'] = "Confirmation code is invalid or has already been confirmed.";
              //$this-&gt;load-&gt;view('index_test', $newsletter_message);
          } else {
              $newsletter_message['newsletter_message'] = "Thank you for confirming your intent to subscribe to our newsletter!";
              $data = array(
                      'nm_subscribed' =&gt; 1,
                      );
              $this-&gt;db-&gt;where('nm_confirmation_code', $code);
              $this-&gt;db-&gt;update('newsletter_members', $data);
              //$this-&gt;load-&gt;view('index_test', $newsletter_message);
          }
  
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>.htaccess file:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond $1 !^([^\..]+\.php|robot\.txt|public|images|css|js|paul|event_docs|blog|citeforme|robots\.txt)
  RewriteRule ^(.*)$ /index.php/$1 [L]
  
  # BEGIN WordPress
  #&lt;IfModule mod_rewrite.c&gt;
  #RewriteEngine On
  #RewriteBase /
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteRule . /index.php [L]
  #&lt;/IfModule&gt;
  #RewriteEngine Off
  # END WordPress
  </code></pre>
  
  <p>Here's what the log file looks like, you can see everything is being reloaded twice:</p>
  
  <pre><code>DEBUG - 2011-09-16 09:59:34 --&gt; Config Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Hooks Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Utf8 Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; UTF-8 Support Enabled
  DEBUG - 2011-09-16 09:59:34 --&gt; URI Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Router Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Output Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Input Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Global POST and COOKIE data sanitized
  DEBUG - 2011-09-16 09:59:34 --&gt; Language Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Loader Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Database Driver Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Controller Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; MyController initialised
  DEBUG - 2011-09-16 09:59:34 --&gt; Helper loaded: form_helper
  DEBUG - 2011-09-16 09:59:34 --&gt; Final output sent to browser
  DEBUG - 2011-09-16 09:59:34 --&gt; Total execution time: 0.0223
  DEBUG - 2011-09-16 09:59:34 --&gt; Config Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Hooks Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Utf8 Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; UTF-8 Support Enabled
  DEBUG - 2011-09-16 09:59:34 --&gt; URI Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Router Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Output Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Input Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Global POST and COOKIE data sanitized
  DEBUG - 2011-09-16 09:59:34 --&gt; Language Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Loader Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Database Driver Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; Controller Class Initialized
  DEBUG - 2011-09-16 09:59:34 --&gt; MyController initialised
  DEBUG - 2011-09-16 09:59:34 --&gt; Helper loaded: form_helper
  DEBUG - 2011-09-16 09:59:34 --&gt; Final output sent to browser
  DEBUG - 2011-09-16 09:59:34 --&gt; Total execution time: 0.0213
  </code></pre>