404 Error Script

Discussion in 'HTML & Website Design' started by theultimatepublishing, Sep 28, 2006.

  1. #1
    Everytime when someone types in a wrong url, (eg. they typed in a url with .htm when the url is acutally .html, or they misspelt something), they'll be sent to a 404 error page.

    How do I create a customized 404 page? Just like marketingtips website.
     
    theultimatepublishing, Sep 28, 2006 IP
  2. jrlane7

    jrlane7 Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Most webhosts allow you to create custom error pages. I would check out your webhost FAQ. My webhost has a link on the control panel with step by step instructions on how to do this.

    Rick Lane
     
    jrlane7, Sep 28, 2006 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    Assuming Apache is your web server, in httpd.conf or in an .htaccess file, set
    
     ErrorDocument 404 /path/my404.html
    Code (markup):
    where my404.html is a regular html document that says what you want your 404 error doc to say. My personal site has this 404 page;
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta name="generator"
            content=
            "HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />        
    
      <title>404 Error | Gary Turner | web development sandbox</title>
    
    <style type="text/css">
    /*<![CDATA[*/
    
    html, body {
        height: 100%;
        margin: 0;
        padding: 0;
        }
    
    body {
        font: 100% verdana, helvetica, sans-serif;
        background-color: #f8f8f8;
        color: #222;
        }
    
    p {
        font-size: 1em;
        }
    
    h1 {
        font: 1.5em georgia, geneva, serif;
        text-align: center;
        }
    
    #wrapper {
        display: table;
        height: 100%;
        width: 100%;
        }
    
    #cell {
        display: table-cell;
        vertical-align: middle;
        }
    
    #inner {
        position: relative;
        margin: 0 auto;
        border: 2px solid black;
        -moz-border-radius: 16px;
        padding: 0 10px;
        width: 75%;
        }
    
    #footer {
        text-align: right;
        }
    
    /*]]>*/
    </style>
    </head>
    
    <body>
      <div id="wrapper">
        <div id="cell">
          <div id="inner">
            <h1>Oops!  There's been a mistake</h1>
            <p>This is known as a &ldquo;404 file not found&rdquo; error.</p>
    
            <p>Try looking at the <a href=
            "/webdev/">webdev index</a> page to find the file you wanted.</p>
    
            <p>--g</p>
            <hr />
    
            <p id="footer">©2005-06 Gary Turner</p>
    
          </div><!-- end inner" -->
        </div><!-- end cell -->
      </div><!-- end wrapper -->
    </body>
    </html>
    Code (markup):
    cheers,

    gary
     
    kk5st, Sep 28, 2006 IP
  4. LongHaul

    LongHaul Peon

    Messages:
    670
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've had what seems like a sudden spike in my custom 404 page being accessed. But I can't figure out what page is referring to it. (The "Referer" field on my recent visitors page is invariably blank.)

    Is there a way to find this out? Or is this a question for my host (hostgator)?

    It seems to often come from a user who only loads a single page. If I had an affiliate link messed up, or a broken image, would the 404.html page show as having been loaded?
     
    LongHaul, Sep 29, 2006 IP