I have the following scenario:
A Codeigniter Website (Lets call it WebA) is installed on the root of the sebserver "/", accessed from the domain: www.example.com.
Another Codeigniter Website (Lets call it WebB) is installed in the same webserver in a subfolder "/subfolder", accessed from the domain: www.example2.com.
I have 2 .htacces files that remove the index.php, installed on WebA and in WebB:
<IfModule mod_rewrite.c>
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]
</IfModule>
<IfModule !mod_rewrite.c>
# 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
</IfModule>
AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
I have configured on WebA in /application/config/config.php:
$config['base_url'] = 'http://example.com/';
And in WebB in /subfolder/application/config/config.php:
$config['base_url'] = 'http://example2.com/';
Error 1:
With This configuration when I access www.example2.com I get:
404 Page Not Found
Error 2:
If I change WebB's .htaccess RewriteBase line to:
RewriteBase /subfolder/
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:
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Trying to get property of non-object</p>
<p>Filename: controllers/html.php</p>
<p>Line Number: 60</p>
</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: Cannot modify header information - headers already sent by (output started at /var/www/subfolder/system/core/Exceptions.php:185)</p>
<p>Filename: helpers/url_helper.php</p>
<p>Line Number: 546</p>
</div>
It also outputs this error when trying to navigate the pages but I get no Html.
The first error seems to be because of the missconfiguration my database models are not working.
Error 3:
If I change WebB's config.php to:
$config['base_url'] = 'http://example.com/subfolder/';
And WebB's RewriteBase line in .htaccess to:
RewriteBase /subfolder/
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/
WebA is always working.
I have the same code working on multiple websites without any problems, but I have never faced this scenario before. Any ideas?