Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET 404 error for style.css not found

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)

like image 291
Priyanka Avatar asked Sep 09 '16 08:09

Priyanka


People also ask

Why is my CSS style not working?

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.

How do you fix the 404 error?

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.

Why is my CSS not connecting to my HTML?

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.


2 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/

like image 113
Tom Avatar answered Oct 17 '22 01:10

Tom


Change <base href="/"> to <base href="./"> from index.html

like image 37
Vikram Sapate Avatar answered Oct 17 '22 01:10

Vikram Sapate