Welcome Guest, Not a member yet? Register   Sign In
CSS and JS files not loading
#1

[eluser]HooJee[/eluser]
Hi Guys

Whenever I load my index page none of my CSS/JS files are loaded, only the HTML text. Does anyone know why this is happening ?
#2

[eluser]davidbehler[/eluser]
Could you post the source code of your index page? That might help.
#3

[eluser]HooJee[/eluser]
Well, its a .htm renamed as a .php - Code below:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;link rel="stylesheet" type="text/css" href="css/index.css" /&gt;
    [removed][removed]
    [removed][removed]
&lt;/head&gt;
&lt;body&gt;

&lt;!-- Content --&gt;

&lt;/body&gt;
&lt;/html&gt;
#4

[eluser]Tyler Diaz[/eluser]
If you're using .htaccess to remove the index.php then this might fix it.

Add this to your .htaccess file and reload.

Options +FollowSymlinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Otherwise, Use Inline CSS via

&lt;style type="text/css"&gt;
/* CSS HERE */
&lt;/style&gt;

At the head of your html document till you find the solution.
#5

[eluser]davidbehler[/eluser]
Where are your css or js files located?
If your folders look like this
Code:
www
-system
--application
-css
-js
then you could try this
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;css/index.css" /&gt;
#6

[eluser]HooJee[/eluser]
Man it sucks being a framework newbie. None of the above sugguestions worked.

My folder dir looks like:

www
-system
--application
---views
----css
----js
#7

[eluser]Tyler Diaz[/eluser]
In that case, feel free to also try.

$this->load->library('parser'); // Unless you havent loaded it already. Big Grin
$this->parser->parse('css/index.css');

Add that to where your CSS link is.
#8

[eluser]HooJee[/eluser]
You'll have to forgive me because I am experiencing a new problem. I deleted and installed the latest version of WAMP because the PHP engine wasnt executing the code. Now that I try to create a simple welcome controller and echo some stuff out I keep getting the following error:

An Error Was Encountered
The URI you submitted has disallowed characters.
#9

[eluser]Tyler Diaz[/eluser]
The Url links based off code igniter can only contain the following characters: a-z 0-9~%.:_-

Your local development must be attatching some kind of extra string to it. If it is for local development only you can go to system > application > config > config.php

Find this:
Code:
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify with a regular expression which characters are permitted
| within your URLs.  When someone tries to submit a URL with disallowed
| characters they will get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

And delete the characters so It'll look like $config['permitted_uri_chars'] = '';

But please, enable the url permitted chars as soon as you can as it is a huge security flaw to go by.
#10

[eluser]HooJee[/eluser]
Aha, cheers that worked. Well, Im using PHP 5.3.0 and CI was spitting out all these depreciated errors until I disabled it in the index.php file. Maybe that could have something to do with it ?

I will try out the above suggestions now and see if they work.




Theme © iAndrew 2016 - Forum software by © MyBB