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)
-
1file path incorrect or file permission problemJYoThI– JYoThI2016-09-09 08:34:48 +00:00Commented Sep 9, 2016 at 8:34
-
i have tried this in the separate folder, it working fine there. but when i am putting all these files into my view folder its giving the error in consolePriyanka– Priyanka2016-09-09 08:38:10 +00:00Commented Sep 9, 2016 at 8:38
-
show me your file structureJYoThI– JYoThI2016-09-09 08:41:10 +00:00Commented Sep 9, 2016 at 8:41
-
Make sure you set your base_url in config.phpuser4419336– user44193362016-09-09 09:21:37 +00:00Commented Sep 9, 2016 at 9:21
-
[This helped me a lot, you should have defined your css,images,js etc.(it is recommended) under any public folder. You can name it as assets/public... ](stackoverflow.com/questions/6630770/…)Priyanka– Priyanka2016-09-10 13:04:41 +00:00Commented Sep 10, 2016 at 13:04
4 Answers
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/