best location for index.php and CI directories? |
[eluser]mt_headed[/eluser]
I've been stumped for literally days trying to resolve what's probably a very basic path issue, in terms of where the index.php and CI files should be stored, so I'm appealing for help... I've using XAMPP for Windows and have successfully configured Apache such that http://localhost points to c:\xampp\htdocs. I've tried storing the CI files in a directory called "ci" under \htdocs, i.e., c:\xampp\htdocs\ci\. My controller and view files are under \ci\system\application.... I've tried moving around the CI files (c:\xampp\htdocs\system (CI dir) as well as the front controller index.php file. At one point I was rewarded with the CI 'welcome' screen, but the only function that worked was the index function in my controller. Any attempt to call a different function either by typing an explicit url or using an anchor link returns a 404. Besides moving around the index.php file: i.e., C:\xampp\htdocs; C:\xampp\htdocs\ci; C:\xampp\htdocs\ci\system etc., I've experimented with the different Config settings, i.e., AUTO, PATH_INFO etc. I've tried changing the front controller settings. I even tried "getting rid" of index.php by creating an .htaccess file, but that diversion just added to my woes, so I've now resolved to go back to basics. I'm hopeful someone can tell me: "Look, idiot, put the CI files here, the index.php there, set your base url as ""... etc." I know 'rudimentary' might be too good a word for this problem and perhaps everyone's got it figured out but me, but forum threads and googling elicit mainly .htaccess arcana, and I can't even get that far. If you know how to set this up, I'd be very grateful. Thanks kindly.
[eluser]Cristian Gilè[/eluser]
Hi mt_headed, 1. download ci 2. extract content to htdocs (so you have index.php and system folder inside htdocs) 3. move the application folder (inside system) at the same level of the index.php file and system folder Now your htdocs is something like this: | |---index.php +---system +---application 4. Optional: if you want you can rename the names of system and application folders. In case that you want rename the folders change the settings in the index.php file accordingly. 5. Open the config.php file (it's in application/config) and set the base_url. In this case will be: Code: $config['base_url'] = "http://127.0.0.1/"; Remember, the guide is your best friend! Cristian Gilè
[eluser]mt_headed[/eluser]
Thanks so much, Cristian. It didn't occur to me to put the application folder at the same level as the system folder. Following your instructions, I managed to get the 'welcome' message to appear. I was also able to set my own controller as the default in the routes config file (as a substitute for 'welcome') and my controller's index function also performed as expected. However, when I try to call a different function from my own controller, whether by typing the segment in manually in the browser (i.e., "http://127.0.0.1/mycontroller/myfunction" or using a link from my menu, I still get the "404 page not found" message. The function I'm trying to call from my controller is almost identical to the index function that does work, except that it loads different view fragments. I checked to ensure that the view files exist in my "http://127.0.0.1/htdocs\application\views" directory. Any thoughts on why this might be happening?
[eluser]Cristian Gilè[/eluser]
Unless you use .htaccess to remove index.php from your urls the Code: http://127.0.0.1/mycontroller/myfunction Change it to Code: http://127.0.0.1/index.php/mycontroller/myfunction For links in your views use the anchor function from url helper that creates a standard HTML anchor link based on your local site URL. To boost the response speed provide your code (controllers and views). Cristian Gilè
[eluser]mt_headed[/eluser]
Sorry, I inaccurately described the url I was using. I simply replaced 'welcome' with 'mycontroller', so the "index.php" is in the url, exactly per your example. I'm still getting the 404.
[eluser]Cristian Gilè[/eluser]
To boost the response speed provide your code (controllers and views). Cristian Gilè
[eluser]Josh Holloway[/eluser]
@mt_headed are you able to supply a snippet of your controller & view? as suggested by Cristian
[eluser]mt_headed[/eluser]
Thanks for prompting me for the code, I was about to grab it when I think I realized my mistake. I had capitalized my controller function, like this. class C1 extends Controller { function C1() { parent::Controller(); } i.e. SHOULD BE function c1()... After changing the case, everything now seems to be working properly again. I'm so relieved that I've given myself a reprieve from proper self-flagellation for being such an idiot. Thank you so much for your assistance, Cristian--your tip on directory structure was a huge help--and for your interest, Josh. Cheers.
[eluser]InsiteFX[/eluser]
Under htdocs just create a directory for each application and copy CI into it. htdocs -- app1 -- app2 etc. InsiteFX |
Welcome Guest, Not a member yet? Register Sign In |