Welcome Guest, Not a member yet? Register   Sign In
404... That really shouldn't be
#1

[eluser]Unknown[/eluser]
Hello,

So, I have been reading the documentation and I am trying to figure out how to get a controller I made to work. The URL is supposed to be http://jessicasideways.info/higherone/ and it is using a controller at application/controllers/higherone.php that has this code:

Code:
<?php

class HigherOne extends CI_Controller {

public function view($page = 'home') {
  if ( ! file_exists('application/views/higherone/'.$page.'.php')) {
   // Whoops, we don't have a page for that!
   show_404();
  }

  $data['title'] = ucfirst($page); // Capitalize the first letter

  $this->load->view('templates/higherone_header', $data);
  $this->load->view('higherone/'.$page, $data);
  $this->load->view('templates/higherone_footer', $data);
}
}
?>

(and the reason why I am not using the pages controller is because I want to use custom headers & footers for mini sites I create on this domain, like this one).

This is what routes I have defined:
Code:
$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['higherone/'] = 'higherone/view';
$route['higherone/:any'] = 'higherone/view/$1';

So, what am I doing wrong?
#2

[eluser]CroNiX[/eluser]
Try changing
Code:
file_exists('application/views/higherone/'.$page.'.php')
to
Code:
file_exists(APPPATH . 'views/higherone/'.$page.'.php')

Also I believe your routes should be, in this order:
Code:
//routes go from most segments to least.
$route['higherone/(:any)'] = 'higherone/view/$1'; //notice () around (:any)
$route['higherone'] = 'higherone/view';
#3

[eluser]Unknown[/eluser]
Thanks, Cronix. Your help is really appreciated. Smile




Theme © iAndrew 2016 - Forum software by © MyBB