![]() |
CI controller function is ignored - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CI controller function is ignored (/showthread.php?tid=30272) |
CI controller function is ignored - El Forum - 05-09-2010 [eluser]den-javamaniac[/eluser] Hi. I'm trying to pass through a CI tutorial (writing a simple forum) and I can't make a controller function called. To be more specific I have this in a controller: Code: function __construct() { Code: function _remap($method){ NOTE: this issue is also discussed here. CI controller function is ignored - El Forum - 05-09-2010 [eluser]erik.brannstrom[/eluser] I copied your code and tried it myself with the only difference that I only echoed a line of text in the index method. For me, everything worked fine so it seems the problem must be something else. Have you set any routes for example? CI controller function is ignored - El Forum - 05-09-2010 [eluser]den-javamaniac[/eluser] Well, I get a very strange error: If routes are not set (some default value is not assigned) like this: Code: $route['default_controller'] = ""; Code: "Unable to determine what should be displayed. A default route has not been specified in the routing file." CI controller function is ignored - El Forum - 05-09-2010 [eluser]erik.brannstrom[/eluser] That error message is displayed when one is trying to access index.php without a default controller set. You said you still got this message when going to index.php/forum/topic/? Have you created a htaccess file? CI controller function is ignored - El Forum - 05-09-2010 [eluser]den-javamaniac[/eluser] You said you still got this message when going to index.php/forum/topic/? - that's correct. Yes, I did. It lies in a project root directory (the same as index.php) and has next content: Code: RewriteEngine on CI controller function is ignored - El Forum - 05-09-2010 [eluser]erik.brannstrom[/eluser] You shouldn't use index.php since you are rewriting the URL. Also, for me it worked if I changed the last line to the following, perhaps that will work for you too. Code: RewriteRule ^(.*)$ index.php/$1 [L] CI controller function is ignored - El Forum - 05-09-2010 [eluser]den-javamaniac[/eluser] Nope, It didn't help me. Could you provide more details on "You shouldn’t use index.php since you are rewriting the URL."? CI controller function is ignored - El Forum - 05-09-2010 [eluser]erik.brannstrom[/eluser] The .htaccess file redirects all requests to your index.php file. This is done so your URLs will look "cleaner", i.e. instead of www.example.com/index.php/forum you go to www.example.com/forum. Have you tried removing the htaccess file completely and then access index.php/forum/topic? CI controller function is ignored - El Forum - 05-09-2010 [eluser]den-javamaniac[/eluser] If I remove .htaccess completely I can easily go to index.php/forum/ and get a proper content. If I remove default controller in remote I still get the error. In fact that file did most certainly nothing (at list I couldn't see any changes/use it properly) so I'm removing it for now. Any other ideas? CI controller function is ignored - El Forum - 05-09-2010 [eluser]erik.brannstrom[/eluser] To me it seems your problem is the htaccess file. Do some searches on the subject, there are a number of standard files for removing index.php from your URLs. As I said before, your CI-code looks alright (though at the moment there is no reason to have the _remap method). Hope it works out! |