I've got this controller called Page
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Page extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index($page = 'home')
{
if ( ! file_exists(APPPATH.'views/'.$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/header', $data);
$this->load->view($page, $data);
$this->load->view('templates/footer', $data);
}
}
but currently it only loads the home.php page by going to http://www.example.com/
I'm trying to make it so if I go to example.com/test it would load test.php
Here are my routes
$route['default_controller'] = 'page';
$route['(:any)'] = 'page/$1';
I am new to php frameworks, and I'm not sure how to achieve this. Any help would be much appreciated.