Question

I have a website hosted by siteground, and my custom 404 page is SOMETIMES missing it's stylesheet. I contacted support but they saw it working fine, assumed I just codded it wrong, and told me to get help form a professional web programmer... (of course I did test before contacting them to be sure it was not my fault) Anyways, the way that siteground allowes you to create a custom 404 page is to add your html code to a form in your control panel, wich creates a 404.shtml in your main folder. The .shtml contains all your html. I have done the following test to narrow down the problem.

  • created a not404.html in my main folder with code copy pasted from my 404.shtml that is in the same folder. It loaded with my stylesheet applied no problem.
  • tried prompting a 404 page with both bad hyperlinks, and by typing pages that do not exist. When I am having the problem with my stylesheet missing, none of thease pages have css, but when I am not having the problem, they all have css applied.

What I think it is: I think that the 404.shtml is not really in my main folder, but just appears to be there, and sometimes that link breaks and the 404.shtml is actualy acessed somewere else on sitegrounds server, therefor the style link would not work properly. This would explain the intermittent css failor. But this is just logic, not understanding.

The only thing I can think of that would be wrong on my end is if there is more than one way to link stylesheets, and my way is a bit unstable. Here is the format I use.

<link type='text/css' rel='stylesheet' href='css/404.css'>

I know this might be a difficult question, but it would be pretty satisfying to figure this out and inform them of the problem with their site.

Was it helpful?

Solution

Change the href for the style tag to be absolute. So this:

<link type='text/css' rel='stylesheet' href='css/404.css'>

Becomes this:

<link type='text/css' rel='stylesheet' href='/path/to/css/404.css'>

OTHER TIPS

css/404.css is a relative path. If the path is something like /path/to/nonextant/page it will try to load the stylesheet from /path/to/nonextant/page/css which does not exist.

Use an absolute path:

/css/404.css
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top