multiple applications |
[eluser]Unknown[/eluser]
I tried to follow: http://codeigniter.com/wiki/Multiple_Applications/ And, I attempted to setup the fully general case at the bottom: /CodeIgniter_x.x.x/ /system/ /application/ /frontend/ /backend/ /webroot index.php .htaccess But, there were some details left out of that page. After some trial and error, I have it working, but either I'm misunderstanding what "baseurl" is used for, or there are problems :-) The part of index.php that I changed: //$application_folder = "application"; $application_folder = MY_BASE_FILE_SYSTEM_DIR . '/application/a'; $uriArr = explode("/", $_SERVER['REQUEST_URI']); if(count($uriArr) > 1){ switch($uriArr[1]) { case 'b': $application_folder = MY_BASE_FILE_SYSTEM_DIR . '/application/b'; break; case 'c': $application_folder = MY_BASE_FILE_SYSTEM_DIR . '/application/c'; break; } } I figured this would support all four of these cases: http://host/a http://host/b http://host/c http://host/ (maps to a) In .htaccess I have: writeEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] (from the user guide) In each application, I had to change config.php (this is under "a"): $config['base_url'] = "http://" . MY_HOST_NAME . "/a/"; $config['index_page'] = ""; But, now for the madness. I assumed that: http://host/a/class/method Would hit class's method (since http://host/a is the base url). But, I kept getting 404 errors. For some random reason, I created a controller called "a", and it loaded! This made no sense to me as it seemed like codeigniter was treating "a" as the class?? Based on this, I modified routes.php: $route['a/(.*)'] = "$1"; And, this works! So, for some reason, in application "a", even though I defined the baseurl as http://host/a, I have to manually strip off the "a" from the route to get things to line up? If this really is correct, I can update the wiki. But, it seems really weird to me. will |
Welcome Guest, Not a member yet? Register Sign In |