0

I am new to codeigniter and really interested in trying it out. I followed the guide but ran into a problem. It seems like I am unable to load my first page properly.

I have inside the view folder another folder called general and inside it index.php.

in controller folder, I have sub-folder with general and inside it is Default controller.

I have the following route and yet the page showing is blank

$route['default_controller'] = "general/default";
$route['404_override'] = '';

When I visit the link, I type this in browser:

http://localhost:8888/treventa/

and the screen is blank. Am I doing something wrong? Sorry if this is too simple but a person got to learn from his mistake :)

2
  • The default_controller must be like folderName/file. Commented Jun 22, 2014 at 15:44
  • I changed it to $route['general/default'] = "/"; and still didn't work... Commented Jun 22, 2014 at 15:49

2 Answers 2

1

Try with me step by step:

  • Firstly: the Controller:

(main.php) File content

if (!defined('BASEPATH'))exit('No direct script access allowed');

class Main extends CI_Controller {

    public function index() {
        $this->load->view('general/welcome');
    }
}
  • Secondly: The view:

(welcome.php) File content
You can put anything you want

<h1> Hello, I'm the view file  </h1>
  • Finaly: The routes:

(routes.php) File content

$route['default_controller'] = "general/main";

Now call the script like this http://localhost/codeIgniter/, that's where codeIgniter is the script folder name.

I think everything now is clear.

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

Comments

0

CI trying to use method default() of general controller. If You want to use folders for controllers, make sure You specify method, so try $route['default_controller'] = "general/default/index";

And one more thing: this method (default_controller) will be used when You trying reach Your root http://localhost:8888/, if You want to route request from http://localhost:8888/treventa/ to default controller, You need to add route-rule to /config/routes.php something like $route['treventa'] = "general/main/index";

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.