GET 404 error for style.css not found
Solution 1
404 is a 'not found' error. Meaning, the browser cannot find your style.css with the path it was given. If it is working on some templates and not others, it is because you may have a different file structure for some templates, a sub-folder for example.
A quick fix would be to make your style.css load from an absolute path
https://yourdomain.com/public/css/style.css
A better solution would be to traverse the directory to the css folder and then reference your style.css.
Learn about relative paths and find a solution that works for all templates. The answer is likely to be something like:
/public/css/style.css
However, it could be something like:
../public/css/style.css
Where goes back to one more previous directory. More about absolute vs. relative paths http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
Solution 2
Change <base href="/">
to <base href="./">
from index.html
Priyanka
Updated on November 01, 2020Comments
-
Priyanka over 3 years
I am currently working on codeigniter framework, in the view i added my custom 404 error's page. But it is not loading the stylesheet from the folder errorpage/web/css/style.css. And i am getting an error in the browser's console GET : url/style.css 404(not found) (url is the address of my folder where my css file is)
-
Priyanka over 7 yearsi have given the relative path but it is still stucked on the same error.
-
Tom over 7 yearstry the absolute path. Your relative path is probably wrong. If you use the absolute path and it works, you then know that is definitely the problem. For further help, post your file structure and the absolute path for your style.css that the browser constructs from the relative path.
-
Priyanka over 7 yearsI am working locally, on giving absolute path <br>Not allowed to load local resource: file:///C:/xampp/htdocs/website/application/views/errorpage/web/images/background.png</br>console is giving this..
-
Tom over 7 yearsYeah of course it will give that error if your try load an image from that directory, load images from a public directory that sits outside of your /application folder. Codeigniter protects files that sit inside /application, keeping them away from the public.
-
Tom over 7 yearsYes, exactly. Take it out and put it in public or Codeigniter will not server it to the public.
-
Priyanka over 7 yearsIs there any way to fix this problem with .htaccess file?
-
Tom over 7 yearsNo. Take the public assets and put them in a publicly accessible directory.
-
Priyanka over 7 yearsThanks a lot Tom, it helped me.