Problem description:
when i navigate to some pages in my web app, the css files are not being loaded / found. I'm getting 404 not found errors and I can't see why. It must be something simple that I'm not seeing.
Specifically, when I navigate to default page, it works (calls the index() method below) but when I try to run the getallswitches() page, none of the css files are loaded.
Code
I have the following CI controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Objects extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('objects_model');
}
public function index()
{
$data['main_content'] = 'default';
$this->load->view('includes/template',$data);
}
public function getallswitches()
{
$switches= $this->objects_model->get_all_switches();
$data['switches']= json_encode($switches);
$data['main_content'] = 'switches';
$this->load->view('includes/template',$data);
}
}
I'm using a templating system to load my views. the template file looks like this:
<?php
$this->load->view('includes/header');
$this->load->view($main_content);
$this->load->view('includes/footer');
?>
Inside my header.php file, I have logic to add css files like so:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>test app</title>
<link href="../application/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="../application/assets/css/justified-nav.css" rel="stylesheet">
<link href="../application/assets/css/dashboard.css" rel="stylesheet">
<script src="../application/assets/js/ie-emulation-modes-warning.js"></script>
</head>
Any tips on what I might be messing up? I've been looking at this too long.
EDIT 1
This is what the URL looks like when it fails:
http://localhost/testapp/index.php/application/assets/css/bootstrap.min.css
And when it works:
http://localhost/testapp/application/assets/css/bootstrap.min.css