Css and Js files does not load in MVC CI

2019-09-21 22:46发布

Header.php

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="/Contents/css/bootstrap.min.css" rel="stylesheet">
        <link href="/Contents/fonts/css/font-awesome.min.css" rel="stylesheet">
        <link href="/Contents/css/animate.min.css" rel="stylesheet">
        <link href="/Contents/css/custom.css" rel="stylesheet">
        <link href="/Contents/css/icheck/flat/green.css" rel="stylesheet">
        <script src="/Contents/js/jquery.min.js"></script>    
    </head>

Login View

    <body style="background:#F7F7F7;">
        ....Html...
    </body>
</html>

Login Controller

<?php
    class loginController extends CI_Controller {

        public function login() {   
            $this->load->View("template/header");
            $this->load->View("login_view");
        }
    }
?>

Content Folder is present in Root Directory. Below is the structure

enter image description here

When I check this in Browser....css and js files does not load. Kindly suggest the corrective action

1条回答
你好瞎i
2楼-- · 2019-09-21 23:40

Add base_url() for each links, like this,

link href="<?= base_url("Contents/css/bootstrap.min.css") ?>" rel="stylesheet">

Change it in all links.

查看更多
登录 后发表回答