My css url is not working in codeigniter

Asked

Viewed 539 times

0

Good morning, I’m learning to use codeigniter, and I’m having a problem with my css... inside the Applications folder I created another folder called layout, which inside it will have a header.php and a footer.php. When I access my view I call this header and footer. Until then ok! in the Applications folder also has another folder called Assets that inside has the following folders - css and Sass.

In my header, I am unable to reach the css file... in my autoload I set the url, and in mine config.php the default url is this way:

$config['base_url'] = 'http://localhost:8888/project_system_hair/project/system_hair/';

and in my header.php is like this:

<link rel="stylesheet" type="text/css" href="<?=base_url('assets/css/teste.css')?>">

When executing and giving element Inspect my href stays this way...

<link rel="stylesheet" type="text/css" href="http://localhost:8888/project_system_hair/project/system_hair/assets/css/teste.css">

That is the way it is right... but the console accuses an error saying:

GET http://localhost:8888/project_system_hair/project/system_hair/Assets/css/teste.css net:ERR_ABORTED and so I can’t use my css.

NOTE: the path of my folder inside the notebook: /Applications/MAMP/htdocs/project_system_hair/project/system_hair/application/Assets/css

Could someone help me? Thank you....

  • try this: <link rel="stylesheet" type="text/css" href="css/test.css"> href do not use "http://localhost..."

  • Try using relative path instead of absolute.

  • You are using the . htaccess file?

  • Yes... has a base url definition and Rewriterule . * index.php/$0 [PT, L]

2 answers

0

Try creating your "layout" folder outside of "Applications", the structure looks something like this:

application
system
layout
    assets
       css
       sass

0


I managed to solve my problem.... From what I was seeing, even if my base url is pointed to application, you’ll have to go the rest of the way.

My solution was by applying/ before getting this way:

<link rel="stylesheet" type="text/css" href="<?=base_url('application/assets/css/teste.css')?>">

This way, my css is "linked" correctly

Personal thank you

  • Dangerous. You’re exposing the core framework on the web, which is not very conducive to the security of its application... (developer says so). Watch the permissions carefully, or manipulate the .htaccess.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.