CodeIgniter Forums
CSS and javascript links - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CSS and javascript links (/showthread.php?tid=32304)



CSS and javascript links - El Forum - 07-19-2010

[eluser]Unknown[/eluser]
Hello everybody !
I am discovering Code Igniter, it seems really nice but I'm turning crazy with the integration of CSS : it won't work !

My folders are organized as follows :
Code:
/
|system |Application
        |the rest...

|static |css -> common.css
             -> menu.css

        |js  -> some js stuff
I've read a lot of things here and on Google, and if I have well understood, I should access my stylesheets with :
Code:
href="<?php echo base_url(); ?>static/css/common.css"

Here is my header.php :

Code:
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>static/css/common.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>static/css/menu.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>static/css/<?php echo  $page; ?>.css" />

    [removed] [removed]
    [removed][removed]
  </head>

My base_url is set to http://localhost/bdac_real/ as code igniter is put in /srv/http/bdac_real

With all that, the page http://localhost/bdac_real/index.php/conferences works fine but with no css and no javascript.

Can you see what I did wrong ?

Thank you.

PS : I'm using Archlinux and PHP5


CSS and javascript links - El Forum - 07-19-2010

[eluser]Buso[/eluser]
are you using .htaccess? If so, you have to exclude static/css from the rewrite rule that adds index.php to every route


CSS and javascript links - El Forum - 07-19-2010

[eluser]KingSkippus[/eluser]
Buso is right, the .htaccess is probably your culprit. Specifically, if you created an .htaccess file as described here to keep from having index.php in all of your URLs, then you need to modify the following line in .htaccess:

Code:
// Old version: RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond $1 !^(index\.php|images|robots\.txt|static)



CSS and javascript links - El Forum - 07-20-2010

[eluser]Unknown[/eluser]
Yes thanks a lot, it was .htaccess' fault, I had forgotten to modify it. Everything seems to be ok now.

Thank you for so quick an answer !