CSS file is not loaded in view file |
[eluser]Magnusvb[/eluser]
Hello This is my first try with CI. And I have some trouble with linking to css files. I have read a lot of the threads about this – but non of the solutions working for me. So here we go I'm using MAMP pro and have created a virtual host "kattliv.ci", which points to the root: - root (kattliv.ci) - application - config - css -images (and all the other folders) - system In the config file, base url is set like this: Code: $config['base_url'] = "http://kattliv.ci/"; In the view file I'm calling a css like this: Code: <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url();?>application/css/master.css"> Which in the output turns out like this: Code: href="http://kattliv.ci/application/css/master.css" But the css file is not loaded in the view. And if I go to that url I get a 404. I'm using a htaccess file to remove "index.php" (the one that is in the User Guide): RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] What am I doing wrong? Regards, Magnus
[eluser]Bernat Bonet[/eluser]
I suggest to place css folder at first level, there you'll not get an error. http://kattliv.ci/projects/project_name/...master.css to http://kattliv.ci/projects/project_name/css/master.css
[eluser]bigtony[/eluser]
You may also want to use the link_tag() function of the CI html helper, e.g. Code: <?php echo link_tag('css/mystyle.css'); ?>
[eluser]Magnusvb[/eluser]
Thanks for your suggestions. But it was the htaccess file that caused the problem. If I removed it the css file was loaded. Moving the css folder outside the application folder did not helped. -- Magnus
[eluser]John_Betong[/eluser]
[quote author="Magnusvb" date="1248349218"]Thanks for your suggestions. But it was the htaccess file that caused the problem. If I removed it the css file was loaded. Moving the css folder outside the application folder did not helped. -- Magnus[/quote] I think that your .hraccess file is preventing your css file from loading. I just did a search on the forum for "RewriteCond css" and came up with the following: Code: rewriteCond $1 !^(index\.php|images|robots\.txt|css) I have not tried this but it looks as though it may solve your problem. 37
[eluser]Magnusvb[/eluser]
Thanks for the tip John. I found another htacces file in this thread: http://ellislab.com/forums/viewthread/83332/ That solved the problem ![]() -Magnus
[eluser]John_Betong[/eluser]
[quote author="Magnusvb" date="1248367365"]Thanks for the tip John. I found another htacces file in this thread: http://ellislab.com/forums/viewthread/83332/ That solved the problem ![]() -Magnus[/quote] Glad to be of help, when can we expect to see your first app?
[eluser]Magnusvb[/eluser]
Quote:Glad to be of help, when can we expect to see your first app?[/quote] Well, I just started ![]() Actually I'm redoing a clients old site (with spaghetti code) on my spare time to learn CI. So if my clients will leave me alone for a week(?!) or so ![]() - Magnus |
Welcome Guest, Not a member yet? Register Sign In |