0

How can I execute a controller i a sub-folder using a URL in Codeigniter?

If I have the next controllers y controllers folder:

-/controllers/
      |---------controller1.php
      |---------/sub-folder/
                     |---------controller2.php

I can execute controller1.php using a URL similar to this: example.com/index.php/controller1/function/param

But, How can I execute controller2.php?

Very important:

=> make sure your sub folder name is not any of the controller's name

=> make sure your class name and file name is same**

2
  • Did you try example.com/index.php/sub-folder/controller2/function/param ? I think codeigniter will allow you to do this up to 1 level of subfolders. Commented Jan 31, 2013 at 8:54
  • @Jeemusu. That doesn't work. My mistake. I forgot to include in question. Commented Jan 31, 2013 at 9:05

2 Answers 2

2

This should work:

 example.com/index.php/sub-folder/controller2/function/param

=> make sure your sub folder name is not any of the controller's name

=> make sure your class name and file name is same

Sign up to request clarification or add additional context in comments.

3 Comments

That doesn't work. My mistake. I forgot to include in question.
404 Page Not Found The page you requested was not found.
check your controller name, make sure the file name and the class name is same
1

You can execute,

example.com/index.php/sub-folder/controller2/function/param

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.