How to load external CSS by CodeIgniter?

Question:

I need to call this external stylesheet but it doesn't load at all, I saw a similar question here, but I haven't noticed a conclusive answer since I'm using CodeIgniter 3 further on.

The error that appears is this:

Failed to load resource: the server responded with a status of 404 (Not Found)

How could I solve this problem?

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8"/>
    <title>RR Telecon</title>
    <link href="images/favicon.ico" />
    <link href="images/favicon.ico" type="image/x-icon" />
    <link href="<?php echo base_url(); ?>/assets/css/bootstrap-theme.css" type="text/css"/>
    <link href="<?php echo base_url(); ?>/assets/css/bootstrap-theme.min.css" type="text/css"/>
    <link href="<?php echo base_url(); ?>/assets/css/bootstrap.css" type="text/css"/>
    <link href="<?php echo base_url(); ?>/assets/css/bootstrap.min.css" type="text/css"/>
    <link href="<?php echo base_url(); ?>assets/css/home.css" type="text/css"/>
</head>
<body>
    <section class="reader">
        teste
    </section>
</body>
</html>

Answer:

Error 404 means it is not finding the file in the indicated location. In the browser console, which line is giving the error? from what I saw there, a slash (/) is missing after the base_url when you call home.php. That could be your problem. replace with the code below and test.

<link href="<?php echo base_url(); ?>/assets/css/bootstrap-theme.css" type="text/css"/>
<link href="<?php echo base_url(); ?>/assets/css/bootstrap-theme.min.css" type="text/css"/>
<link href="<?php echo base_url(); ?>/assets/css/bootstrap.css" type="text/css"/>
<link href="<?php echo base_url(); ?>/assets/css/bootstrap.min.css" type="text/css"/>
<link href="<?php echo base_url(); ?>/assets/css/home.css" type="text/css"/>

But I would have to see if your base_url has the slash (/) at the end. if it does, you will need to remove all the slashes when you place the link. Staying like this:

    <link href="<?php echo base_url(); ?>assets/css/bootstrap-theme.css" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/bootstrap-theme.min.css" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/bootstrap.css" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" type="text/css"/>
<link href="<?php echo base_url(); ?>assets/css/home.css" type="text/css"/>

Try it both ways and see what happens 🙂

Scroll to Top
AllEscort