1
votes

I am working with codeigniter. But CSS is not working even I use base url() function.

< link href="< ? php echo base_url(); ?> application/views/vehicle/css/bootstrap.min.css" rel="stylesheet" media="screen" />

If I just echo base url(), it outputs

http://localhost/codeigniter/

My css is in

C:\xampp\htdocs\codeigniter\application\views\vehicle\css

Can someone please help me with this?

2

2 Answers

1
votes

Your css file should be in publicly approachable directory. Application directory (application or APPPATH) is not publicly reachable. So your CSS file should be somewhere next to index.php file of your application. It is common to have assets/css path started in your website root:

-application
-system
-assets
--css
---vehicle.css
-index.php
-.htaccess

And if you make your web application code that uses CSS files dinamicaly regarding of route used, you can resolve it by adding more related subfolders:

-application
-system
-assets
--css
---vehicle
----style.css
-index.php
-.htaccess

This way, after url helper is loaded, you could reach css link with:

<?php echo base_url('assets/css/vehicle/style.css');?>

Eventualy you should include assets location in .htaccess file enabling Apache server to allow reading of it.

0
votes

Maybe because of the ">" closing tag before "media".

Maybe you could try with relative path. So use as many "../" as needed to go back into parent folder untill you reach root dir (if your php file is in a sub-folder) and then add the path to the CSS file.