I am trying to get this URL to work on a codeigniter installation, just installed the newest version today (2.0.2):
http://mydomain.com/pete/ci_test/accounts
So I have set my default controller in routes.php to test.php, and inside my controller, test.php I have this code:
class test extends CI_Controller {
public function index() {
$this->load->view('test');
}
public function accounts() {
$this->load->view('accounts');
}
}
and then I have a test.php and an accounts.php inside my views, it loads the test.php view when I go to http://mydomain.com/pete/ci_test/
But when I go to http://mydomain.com/pete/ci_test/accounts it gives me a 404. I have been reading the Getting Started and it says “By default CodeIgniter uses a segment-based approach”, and then gives an example similar to what I’m doing. But then I read a little further it says: “By default, the index.php file will be included in your URL” . So I added this into my htaccess file (located at mydomain.com/pete/ci_test/.htaccess):
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
I made sure that the module is loading inside httpd.conf. It still doesn’t go to my accounts.php view. I have also tried:
http://mydomain.com/pete/ci_test/index.php/accounts
But another 404, what am I doing wrong? Any advice would help, thank you!
Default controller is what loads when there are no url segments present – that’s it.
If you want
/accountsto load thetestcontroller andaccountsmethod, you’ll have to use a route like this:Otherwise you’ll have to have an accounts controller or access it through
/test/accounts/