I am having problems with my routing. My default controller (mysite.com) will work, but if I try anything else (e.g. mysite.com/dashboard), it goes to a server based 404, not a CodeIgniter one. It's very confusing, as at the moment I only have 2 paths in my routes.php file. Here are the non-commented sections of my routes.php file:
$route['404_override'] = '';
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
My controller is located in /application/controllers/pages.php.
I don't think its a .htaccess issue (as it can get to the default controller), but here is my .htaccess file:
RewriteEngine On
RewriteCond $1 !^(index\.php|styles|scripts|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
#<IfModule mod_gzip.c>
# mod_gzip_on Yes
# mod_gzip_dechunk Yes
# mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
# mod_gzip_item_include handler ^cgi-script$
# mod_gzip_item_include mime ^text/.*
# mod_gzip_item_include mime ^application/x-javascript.*
# mod_gzip_item_exclude mime ^image/.*
# mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
#</IfModule>
Edit
Here is the pages controller:
<?php
class Pages extends CI_Controller {
public function __construct()
{
//Construct it's parent
parent::__construct();
//Check login
//$this->load->model('pages_model');
//$this->pages_model->getLoginStatus();
}
public function view($page = 'dashboard')
{
//If the file doesn't exist
if ( ! file_exists('/var/www/vhosts/mysite/httpdocs/library/application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
//Load all necessary views
$this->load->view('templates/head', $data);
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
?>
had your same problem just now , simply move .htaccess file to the root of your working directory
just take it out of application folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With