title: 2 Codeigniter Installations on the same server with subfolder
body: <h2>I have the following scenario:</h2>
  
  <p>A Codeigniter Website (Lets call it <strong>WebA</strong>) is installed on the root of the sebserver "/", accessed from the domain: www.example.com.</p>
  
  <p>Another Codeigniter Website (Lets call it <strong>WebB</strong>) is installed in the same webserver in a subfolder "/subfolder", accessed from the domain: www.example2.com.</p>
  
  <p>I have 2 .htacces files that remove the index.php, installed on WebA and in WebB:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  
  #Removes access to the system folder by users.
  #Additionally this will allow you to create a System.php controller,
  #previously this would not have been possible.
  #'system' can be replaced if you have renamed your system folder.
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]
  
  #When your application folder isn't in the system folder
  #This snippet prevents user access to the application folder
  #Submitted by: Fabdrol
  #Rename 'application' to your applications folder name.
  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]
  
  #Checks to see if the user is attempting to access a valid file,
  #such as an image or css document, if this isn't true it sends the
  #request to index.php
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
  
  RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} (auth|register|secure)
  RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]
  
  RewriteCond %{HTTPS} on
  RewriteCond %{REQUEST_URI} !(static|auth|register|secure)
  RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]
  
  &lt;/IfModule&gt;
  
  &lt;IfModule !mod_rewrite.c&gt;
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin
  
  ErrorDocument 404 /index.php
  &lt;/IfModule&gt;
  
  AddType application/vnd.ms-fontobject .eot
  AddType application/octet-stream .otf .ttf
  </code></pre>
  
  <p>I have configured on WebA in /application/config/config.php:</p>
  
  <pre><code>$config['base_url'] = 'http://example.com/';
  </code></pre>
  
  <p>And in WebB in /subfolder/application/config/config.php:</p>
  
  <pre><code>$config['base_url'] = 'http://example2.com/';
  </code></pre>
  
  <h2>Error 1:</h2>
  
  <p>With This configuration when I access www.example2.com I get:</p>
  
  <p>404 Page Not Found</p>
  
  <h2>Error 2:</h2>
  
  <p>If I change WebB's .htaccess RewriteBase line to:</p>
  
  <pre><code>RewriteBase /subfolder/
  </code></pre>
  
  <p>I get the html outputted, in the index "http://example2.com/" but it will not load any of my JS or CSS, because instead of loading the script it loads this:</p>
  
  <pre><code>&lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Trying to get property of non-object&lt;/p&gt;
  &lt;p&gt;Filename: controllers/html.php&lt;/p&gt;
  &lt;p&gt;Line Number: 60&lt;/p&gt;
  
  &lt;/div&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"&gt;
  
  &lt;h4&gt;A PHP Error was encountered&lt;/h4&gt;
  
  &lt;p&gt;Severity: Warning&lt;/p&gt;
  &lt;p&gt;Message:  Cannot modify header information - headers already sent by (output started at /var/www/subfolder/system/core/Exceptions.php:185)&lt;/p&gt;
  &lt;p&gt;Filename: helpers/url_helper.php&lt;/p&gt;
  &lt;p&gt;Line Number: 546&lt;/p&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>It also outputs this error when trying to navigate the pages but I get no Html.</p>
  
  <p>The first error seems to be because of the missconfiguration my database models are not working.</p>
  
  <h2>Error 3:</h2>
  
  <p>If I change WebB's config.php to:</p>
  
  <pre><code>$config['base_url'] = 'http://example.com/subfolder/';
  </code></pre>
  
  <p>And WebB's RewriteBase line in .htaccess to:</p>
  
  <pre><code>RewriteBase /subfolder/
  </code></pre>
  
  <p>Its working fine, when accessed by www.example.com/subfolder/ and www.example2.com, but the problem are the WebB's links, which I need them to be as www.example2.com and not www.example.com/subfolder/</p>
  
  <p>WebA is always working.</p>
  
  <p>I have the same code working on multiple websites without any problems, but I have never faced this scenario before. Any ideas?</p>