CSS does not work on pages generated with Errordocument

Asked

Viewed 225 times

1

I’m having a problem when I’m customizing ERROR 404. I put the following code in the . htaccess file:

ErrorDocument 404 /erro404.html

And I created a custom page error404.html. The page is onpage, there is no link to other pages.

When I type e.g. meusite/contact falls into erro404.html, so far so good. But when I type for example. meusite/contact/ (bar) it does not pull the css (gets all unknowable). What can be?

  • Try to put in your HTML inside the head the following tag: <base href="/" target="_Blank">

  • Still continues Felipe :(

  • "...But when I put it by e.g. meusite/contact/ (bar) it doesn’t pull the css (gets all messed up)..." But what happens? Show page 404 but no css?

  • That. If I put / at the end of qq word, it opens the page without css :/

  • So you put the tag I sent up on the erro404.html page?

  • I had put in index rs Now I put in erro404 page, appeared the image I had put, but the texts still remains disfigured.

  • erro404.html page you have the link to CSS, you can copy and paste here?

  • <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">&#xA;&#xA;<link rel="stylesheet" type="text/css" href="css/bootstrap.css">&#xA; &#xA; <link rel="stylesheet" type="text/css" href="css/style.css">&#xA;&#xA; <link rel="stylesheet" type="text/css" href="css/responsive.css">

  • Try as follows: <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon"> <link rel="stylesheet" type="text/css" href="/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="/css/style.css"> <link rel="stylesheet" type="text/css" href="/css/Responsive.css.css">

  • Wonder @Filipemoraes !! Now It’s Worked/ Thank You =D

  • Wonderful! I will post as an answer.

Show 6 more comments

2 answers

2


Change the links in your css to point to the server root, for example, if this is the case:

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

Change and put like this:

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

See that there is a difference in href, has a slash at the beginning, this indicates that your css file is inside the css folder that is at the server root.

  • PERFECT! It worked correctly ;)

1

Add the following html code to your erro404.html page:

If css, js and images folders are at the root:

<base href="/">

Or you could try this:

<base href="http://www.examplo.com/">

This tag points to that the Resources click as if they were on the page specified in <base>.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

  • William, as he accepted your reply, I suggest adding what I wrote below as a response, is lacking information. Look at the comments that are in the question. I say this because the answer can help others if it is more complete. Hug.

  • @Filipemoraes Sorry that information, I only see about the <link>, the base tag is to work as if it were on the specified page. They are alternative methods.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.