How to configure when putting CodeIgniter into existing site |
[eluser]Unknown[/eluser]
I also posted this to stackoverflow, but I think the real experts are here! I have an existing "straight" PHP site at http://www.mysites.com/site1/ and want to migrate it to CodeIgniter over time. I know there are a few ways to do this, but I'd like to leave the existing site alone and just put the CodeIgniter folder (CI) in the root directory (site1), then redirect requests to it if the file or directory doesn't exist. So this .htaccess file is in the site1 folder: RewriteEngine on RewriteBase /site1/CI/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|assets) RewriteRule ^(.*)$ index.php/$1 [L] and this .htaccess file is in the site1/CI folder (needed?): RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|assets) RewriteRule ^(.*)$ index.php/$1 [L] and the CodeIgniter config.php file contains: $config['base_url'] = 'http://www.mysites.com/site1/CI/'; This works fine if I try to go to a location on the existing site (e.g., http://www.mysites.com/site1/page.php), but if I try to go to a page that should be routed to CodeIgniter (e.g., http://www.mysites.com/site1/home), I get a 404 error from CodeIgniter. It appears to be looking for method 'home' in controller 'site1' instead of controller 'home'. So I then tried this .htaccess file in the root directory to get rid of 'site1' being passed to index.php: RewriteBase /site1/CI/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|assets) RewriteRule /site1/(? ![]() Unfortunately, that caused Apache to return a 404. I even tried this in the routes.php file: $route['site1/(:any)'] = "$1"; which sorta worked, but page links were bad. Any ideas? Is there a 'best practice' for configuring this set up? |
Messages In This Thread |
How to configure when putting CodeIgniter into existing site - by El Forum - 11-18-2013, 03:35 PM
How to configure when putting CodeIgniter into existing site - by El Forum - 11-19-2013, 05:12 AM
How to configure when putting CodeIgniter into existing site - by El Forum - 11-19-2013, 02:51 PM
|