title: CodeIgniter returns 404 Not Found when installed in a subdirectory on nginx
body: <p>A website - let's call it fru.it - servers a CodeIgniter application under fru.it/blueberry trough nginx and PHP-FPM. 
  The main site resides in <code>/var/www/fru.it/</code> on the filesystem, while the app is under <code>/var/www/fru.it_blueberry/blueberry/</code> (different root than the main site). 
  In an attempt to tighten security while CodeIgniter was upgraded to 3.1.0, the app's file structure was changed as per <a href="https://codeigniter.com/user_guide/general/managing_apps.html" rel="nofollow">the CodeIgniter User Manual</a> to: </p>
  
  <pre><code>/var/www/fru.it_blueberry/
  ├── blueberry
  │   ├── application
  │   ├── docs
  │   ├── public
  │   │   ├── index.php
  │   └── system
  └── sock
  </code></pre>
  
  <p>On development machines the setup works fine with Apache2's default mod_rewrite rules shipped with CI. Accessing fru.it/blueberry/ on the production server, however, displays a CI 404 page. </p>
  
  <p>I'm sure it's a misconfiguration but I can't find the right detail by myself and have been trying with <a href="https://github.com/allanfreitas/codeigniter-nginx/blob/master/example.com" rel="nofollow">different setups</a>. What do I need to change? </p>
  
  <h2>Application Configuration</h2>
  
  <p>The index file is modified to point to absoulte paths of diretories that got moved out of the public root: </p>
  
  <pre><code>$system_path = '/var/www/radiostudent.si_klubskimaraton/klubskimaraton/system'
  $application_folder = '/var/www/radiostudent.si_klubskimaraton/klubskimaraton/application';
  </code></pre>
  
  <p>This is from <code>application/config/config.php</code>: </p>
  
  <pre><code>$config['base_url'] = '';
  $config['index_page'] = 'index.php';
  $config['uri_protocol'] = 'AUTO';
  $config['log_threshold'] = 4;
  </code></pre>
  
  <p>In <code>application/config/routes.php</code>, a default controller is set to display the homepage at the bare address: </p>
  
  <pre><code>$route['default_controller'] = "Welcome";
  $route['404_override'] = '';
  </code></pre>
  
  <h2>Application Log</h2>
  
  <pre><code>INFO - 2016-09-02 12:16:19 --&gt; Config Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; Hooks Class Initialized
  DEBUG - 2016-09-02 12:16:19 --&gt; UTF-8 Support Enabled
  INFO - 2016-09-02 12:16:19 --&gt; Utf8 Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; URI Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; Router Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; Output Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; Security Class Initialized
  DEBUG - 2016-09-02 12:16:19 --&gt; Global POST, GET and COOKIE data sanitized
  INFO - 2016-09-02 12:16:19 --&gt; Input Class Initialized
  INFO - 2016-09-02 12:16:19 --&gt; Language Class Initialized
  ERROR - 2016-09-02 12:16:19 --&gt; 404 Page Not Found: /index
  </code></pre>
  
  <h2>Webserver Configuration</h2>
  
  <pre><code>location /blueberry {
      error_log /var/www/radiostudent.si_klubskimaraton/main-error.log debug;
      rewrite_log on;
      alias   /var/www/fru.it_blueberry/blueberry/public;
      index   index.html index.htm index.php;
      try_files $uri $uri/ /index.php;
  
      location ~* \.php$ {
              error_log /var/www/radiostudent.si_klubskimaraton/php-error.log debug;
              rewrite_log on;
              try_files $uri $uri/ /index.php =404;
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              include fastcgi_params;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $request_filename;
              fastcgi_pass @php-blueberry;
  
      }
  }
  </code></pre>