0

I am wondering if there is any other configuration options for a default controller.

For example - if I have a controller called "site" and I set the default controller in the following file: application/config/routes.php to:

$route['default_controller'] = "site";

I should be able to go to http://localhost and that brings up the index(); function in the site controller.

However, if I try to do go to http://localhost/index.php/index2 to load the index2(); function I get a 404 error. If I change the URL to http://localhost/index.php/site/index2 it works fine - but I thought already set the default controller. Is there any way around this?

3 Answers 3

2

The only way to do it is manually writing the routing rule:

$route['index2'] = "site/index2";
Sign up to request clarification or add additional context in comments.

Comments

0

You cannot do that.

The default_controller is only for URLs without any URI parameter. How could CodeIgniter distinguish between a method name and a controller name?

What you can do: define a redirect inside your 404 document or directly map your 404 document to index.php

Comments

0

No CI doesn't work like that the first parameter has to be the name of a controller, so in this case you would have to create a controlled called "index2".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.