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)
Make sure the link tag is at the right place If you put the <link> tag inside another valid header tag like <title> or <script> tag, then the CSS won't work. The external style CAN be put inside the <body> tag, although it's recommended to put it in the <head> tag to load the style before the page content.
The simplest and easiest way to fix your 404 error code is to redirect the page to another one. You can perform this task using a 301 redirect. What's 301, you may ask? It's a redirect response code that signals a browser that the content has been transferred to another URL.
When your HTML and CSS files are not on the same folder, you might have some challenges linking them. You can resolve this problem by: Using the correct file path to the CSS file. So if the CSS file is in a different folder from the HTML path, you need to identify the path name and add it to the link href value.
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/
Change <base href="/">
to <base href="./">
from index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With