![]() |
External Stylesheets not working anywhere! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: External Stylesheets not working anywhere! (/showthread.php?tid=9637) Pages:
1
2
|
External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]chaderick[/eluser] Alright, I've read through the forum topics for several days now, and I still can't seem to fix my problem. No matter what I do, my external CSS files just aren't working. I've tried putting the css in different places: --public/css/test.css --system/application/css/test.css --system/application/views/test.css And then I've tried each of those using the various linking methods: Code: // in the controller: Code: // and in the view Code: <?= link_tag($testcss); ?> Yes, I have short tags enabled. Yes, the base url is set correctly. In each instance I have viewed the source to check that the css link was being put on the page. It's there. The path is correct. I've even checked file permissions on my server to make sure the files were accessible. They are. I've included the html and url helpers as well. To make sure I had the css written correctly, I pasted it inline and viewed the file again. The css does work inline, just not externally. Does anyone have any clue what might be going on here? I've been working in PHP for several years but am new to Code Igniter. Thanks! External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]Sarfaraz Momin[/eluser] can you post the links where the CSS file is and what link is generated in the HTML. The best way to know is to copy the path in the HTML which links to the CSS file and paste in the address bar in the browser and see if u get the CSS file. It would tell u what the issue is. Good Day !!! External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]Chris Newton[/eluser] Put your CSS wherever you'd like, then target that url. Try putting it in the folder '/css/test.css' for instance '/' being the root of your site, not your CI install. From CI, you can then call it with Code: <?= link_tag(base_url().'css/test.css'); ?> Code: <link href="http://yoursite.com/css/test.css" rel="stylesheet" type="text/css" /> If you're having trouble targetin the CSS, the easiest way to find out where your script is *trying* to call it, is to look in your web pages source output. You'll see exactly where CI thinks it's located. External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]chaderick[/eluser] That is a good idea... Alright, when pasting the link into the address bar, I'm getting the 404 page not found error; however, when I look into the directory I can confirm that the file is actually there. This means that code igniter is not finding the file. Okay, this is something to do with .htaccess. If I take out Code: RewriteRule ^(.*)$ /index.php/$1 [L] and then put the "/index.php/" back in the url, THEN the CSS works. External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]richthegeek[/eluser] you perhaps need to add some rules to your htaccess regex to ignore css, js, png, jpeg, jpg, gif, and pdf files External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]chaderick[/eluser] Alright, that did it. Problem solved. I added css and public to the exceptions on my rewrite conditions. Thanks! External Stylesheets not working anywhere! - El Forum - 07-02-2008 [eluser]louis w[/eluser] It's much better to use this in your htaccess: RewriteCond %{REQUEST_FILENAME} !-f Instead of maintaining a list of exceptions. This says if the request is NOT a file on the server then continue. External Stylesheets not working anywhere! - El Forum - 09-15-2009 [eluser]byrnef87[/eluser] Thanks heaps louis w, you just fixed a problem that has been vexing me for the past hour! External Stylesheets not working anywhere! - El Forum - 09-15-2009 [eluser]wiredesignz[/eluser] [quote author="louis w" date="1215053365"]... use this in your htaccess: RewriteCond %{REQUEST_FILENAME} !-f Instead of maintaining a list of exceptions...[/quote] Wrong and very lazy. Any missing file being requested will force a redirect to index.php and cause CodeIgniter to run your application again. The exceptions list based on the current application structure is more appropriate for a professional developer. External Stylesheets not working anywhere! - El Forum - 09-15-2009 [eluser]Phil Sturgeon[/eluser] Any missing file will go to CodeIgniter then show your page's standard 404 which makes it all more uniform. The same can be re-created with .htaccess ErrorDocument 404 but it is all the same in the end. Either way, CodeIgniter will be handling my 404's so this is a non-issue. |