title: CodeIgniter: server name without www does not pick the correct DB config
body: <p>If I go to url of <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> I get a nice redirect to <a href="http://www.example.com/site/index.php/home/main" rel="nofollow noreferrer">http://www.example.com/site/index.php/home/main</a> just as I want using the .htaccess file.</p>
  
  <p>If I cut the WWW part, meaning <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> then I get the following error:</p>
  
  <pre><code>An Error Was Encountered
  No database connection settings were found in the database config file.
  </code></pre>
  
  <p>My htaccess file:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /example/index.php?/$1 [L]  
  
  RedirectMatch 301 ^/$ /home/main/
  </code></pre>
  
  <p>while in database.php I have</p>
  
  <pre><code> if (
      ($_SERVER['SERVER_NAME'] == 'www.example.com') 
      or ($_SERVER['SERVER_NAME'] == 'example.com') 
      or ($_SERVER['SERVER_NAME'] == 'example.anothersite.com')
      or ($_SERVER['SERVER_NAME'] == "NN.NN.NN.NN")
  )
  {
      $db['default']['hostname'] = 'localhost';
      $db['default']['username'] = .....
  </code></pre>
  
  <p>What am I missing? I need it to work with or without WWW and it seems to be an issue in my CodeIgniter since the error is a CodeIgniter one.</p>
  
  <p>Thank you!</p>