• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Directory navigation

Hello there and nice to meet you. I am a new CI member and my name is Jose.

I have the next directory structure inside my root folder:

-> assets
-> secured_folder
|---> index.php

To reference the css code from inside the index.php view file (located at /secured_folder/secured_application_folder/views) I need to just go up one level, like this:

<link href="../assets/css/bootstrap.min.css" rel="stylesheet">

Apparently this is not true, I would have to go up three levels: from "views" folder to "secured_application_folder"; from "secured_application_folder" to "secured_folder", and from "secured_folder" to my root folder.

This code won't work, though:

<link href="../../../assets/css/bootstrap.min.css" rel="stylesheet">

Why is this happening? Huh


try making your link tag look like this:

<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" rel="stylesheet">
"I reject your reality and substitute my own" - Adam Savage, M5 Inc.

Thanks Hobbes for your answer. I tried it but now nothing appears in my webpage (like if the <body> tag were not rendering its contents properly)

Why is that? I just replaced this line:

<link href="../assets/css/bootstrap.min.css" rel="stylesheet">

With this one:

<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" rel="stylesheet">

The complete index.php file looks like:

PHP Code:
<!DOCTYPE html>
html lang="en">
title><?php echo $title ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- Bootstrap core CSS -->
        <link href="../assets/css/bootstrap.min.css" rel="stylesheet">
        <div class="container">
            <h3>Hello! This is some text inside the "container" class.</h3>
            <div class="row">
                <div class="col-md-8">.col-md-8</div>
                <div class="col-md-4">.col-md-4</div>


I must remark anyway that, using the first line of code I stated in this answer, the page will load successfully with the .css file properly loaded. The thing is that I don't know why I just have to go up 1 level (i.e. why I have to use ../ once) instead of 3 times.

Thanks in advance for your help.

You have to place your assets folder directly under the root


Then you can acces your assets with a url like "/assets/..."


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.