1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How can I change my 404 page with Hostgator?

Discussion in 'Site & Server Administration' started by powwka, Aug 20, 2008.

  1. #1
    I'm using an addon domain with my Hostgator account, and I want to change the 404 error page for this domain. Hostgator has a thing where you can change error pages, but I think that changes it for all domains on that account.
    I only want to change it for this one domain. Is that possible?
    I Googled it and tried something with the .htaccess file but it didn't change anything.
     
    powwka, Aug 20, 2008 IP
  2. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #2
    Add below line in your htaccess file. Probably it wil help you:

    ErrorDocument 404 /404.html

    Kailash
     
    kailash, Aug 21, 2008 IP
  3. powwka

    powwka Peon

    Messages:
    583
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah that's what I tried doing and it didn't change anything.
     
    powwka, Aug 21, 2008 IP
  4. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #4
    You must put the errordocument directive in the respective addon domain folder for it to be processed by that documentroot
     
    zacharooni, Aug 22, 2008 IP
  5. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #5
    Did you create a page named 404.html and upload it to the addon domain root directory?
     
    mjewel, Aug 22, 2008 IP
  6. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #6
    this is my 404 page setup, call it 404.php

    <?php
    $sendMail = "no";   // must be set to "yes" for the email to be sent
    $emailAddress = "you@yourdomain.com";  // set to your email address
    putenv('TZ=EST5EDT');  // set to your time zone
    // change nothing below this line
    $domain = $_SERVER['HTTP_HOST'];
    $page = $_SERVER['REQUEST_URI'];
    if ($sendMail == "yes") {
      $errortime = (date(" F d h:ia"));
      $browser = $_SERVER['HTTP_USER_AGENT'];
      $referer = $_SERVER['HTTP_REFERER'];
      $IP = $_SERVER['REMOTE_ADDR'];
      $message = "";
      $message .= "Time of the error: $errortime\n\n";
      $message .= "browser: $browser\n\n";
      $message .= "Page Requested: $domain$page\n\n";
      $message .= "Referer: $referer\n\n";
      $message .= "IP Address: $IP\n\n";
      $name = gethostbyaddr($IP);
      $message .= "Hostname: $name\n\n";
      mail($emailAddress, "404 Error" , $message, "From: Website <>");
    }
    header("HTTP/1.0 404 Not Found");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="refresh" content="1;url=http://www.sawz.com/">
    <title>404 - where oh where?</title>
    <style type="text/css">
    A:link {text-decoration: none; font-weight:bold; color: blue}
    A:hover {color: red}
    </style> 
    </head>
    <body>
    <div style="width: 400px; position: absolute; top: 45px; left: 50%; margin-left: -200px;">
    <span style="color: teal; font-size: 32px;">file not found</span>
    <br /><br /><br />
    <span style="color: black; font-size: 18px;">
    (oops)
    <br /><br />
    it appears you were looking for
    <br />
    <span style="color: teal; font-size: 18px;"><?=$domain?><?=$page?></span>   
    <br /><br />  
    however, since you are here, it is clear you did not get what you wanted.
    <br /><br />  
    the problem has been reported so any broken links can be found and repaired.
    <br /><br />  
    you can click <a href="javascript:history.go(-1)">here</a> to go back to your previous page.
    </span>
    </div>
    </body> 
    </html> 
    Code (markup):
    then add this to your htaccess:

    ErrorDocument 404 /404.php
    Code (markup):
    works for me.
     
    sawz, Aug 22, 2008 IP
  7. powwka

    powwka Peon

    Messages:
    583
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I've tried pointing the ErrorDocument to a bunch of different places - the root, different pages, and nothing works. I think it has something to do with Hostgator.
     
    powwka, Aug 22, 2008 IP
  8. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #8
    It works fine with hostgator, including the site in my sig.
     
    mjewel, Aug 22, 2008 IP
    powwka likes this.
  9. powwka

    powwka Peon

    Messages:
    583
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks, I figured out the problem. I went to your site and typed in a wrong page and I got the same generic 404 error. I was using IE7, so I tried FF and your 404 page showed up.
    So it's just an IE7 issue.
     
    powwka, Aug 22, 2008 IP
  10. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    310
    #10
    It works with ie7 here. Try clearing your cache.
     
    mjewel, Aug 22, 2008 IP
  11. powwka

    powwka Peon

    Messages:
    583
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I tried that and it didn't work. I did some more googling and found that I needed to uncheck "Show friendly HTTP error messages" in my Internet Options.
    Now it shows my Wordpress 404 page, which is good enough. I still can't get the ErrorDocument thing to work, but I'm probably putting it in the wrong place in the .htaccess file. I did try putting it before #Begin wordpress and after #End wordpress and neither worked.
     
    powwka, Aug 22, 2008 IP
  12. khucthuydu

    khucthuydu Member

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #12
    i hate hostgator... lol with 404 error page

    They adv on my site .
     
    khucthuydu, Jan 27, 2011 IP
  13. LightBall

    LightBall Greenhorn

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #13
    Htaccess or php method. They are the only ways i guess
     
    LightBall, Feb 9, 2011 IP
  14. ColorHost-Kevin

    ColorHost-Kevin Member

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #14
    htacess is perfect for doing this, Hostgator is weird with there error pages.
     
    ColorHost-Kevin, Feb 13, 2011 IP