Welcome Guest, Not a member yet? Register   Sign In
How to configure when putting CodeIgniter into existing site
#3

[eluser]Unknown[/eluser]
I finally got everything working for putting a CI application inside an existing site one folder level deep. Here is how I did it.

Folder structure used:

site1
....page1.php
....page2.php
....etc....
....CI
.........application
.........assets
.........system
site2
site3

.htaccess in site1 folder:
Code:
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond $1 !^(images|robots\.txt|assets)
RewriteRule ^(.*)$ CI/index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 ^assets
RewriteRule ^(.*)$ CI/$1 [L]

Note that I took the usual "index\.php" out of the third RewriteCond in the first block (because of HybridAuth and CodeIgniter routing described below). The second block is to redirect CodeIgniter page references to the assets folder to the assets folder inside the CI folder. (Otherwise I'd have to move the assets folder to the site1 folder.)


This is the base url in the config.php file:
Code:
$config['base_url'] = 'http://www.mysites.com/site1/';


I had to add the following to the routes.php file inside the CI config folder:

Code:
$route['site1/index\.php/(:any)'] = "$1";
$route['site1/(:any)'] = "$1";

Even after the Apache redirect, CI still sees "site1" in the URI and, therefore, try to load the "site1" controller which obviously doesn't exist! The second $route[] takes "site1" away.

I'm also using HybridAuth which includes "index.php" in its callbacks, so CI will see it in the URI and try to load the "index.php" controller which obviously doesn't exist either! The first $route[] takes "site1/index.php" away.

Hopes this helps someone.


Messages In This Thread
How to configure when putting CodeIgniter into existing site - by El Forum - 11-19-2013, 02:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB