Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the CSS on the server error page work?

On my website, I have a custom 404 error page. On the main directory (root), the server loads up 404.html along with the linked CSS file. The problem is, that if I visit a separate directory in the root, and initiate a 404 error, server loads up the error page, but the CSS of the error page doesn't load up.

Here is what I'm talking about:

Here is the error page that loads up:

http://kunal.vr.lt/aervaavtrq4

Here is the error page that loads up inside another directory:

http://kunal.vr.lt/documents/asdfawef78

How will I make the CSS load when an error page on another directory is shown? I don't want to put a 404.html in every single folder, and I don't want to embed the CSS inside the HTML

I run WAMP using apache 2.4.9

like image 413
Kunal Chopra Avatar asked Apr 14 '26 13:04

Kunal Chopra


1 Answers

Change your link reference to (with leading slash):

<link href="/htmlcss.css" rel="stylesheet" type="text/css">

You were using a reference to the page being viewed. So in the other page, it was trying to load /documents/htmlcss.css.

Per the above, you should be using a reference relative to the root of your domain.

like image 101
Mike Rockétt Avatar answered Apr 17 '26 09:04

Mike Rockétt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!