need help with 404 redirect

Discussion in 'PHP' started by cscorp, Apr 23, 2009.

  1. #1
    I know this has been discussed before..but I just can't seem to get it to work correctly.

    Simply trying to re-direct all 404 pages to my index.php.

    I am using cpanel with hostgator: Linux CentOS

    I have the followng line of code in my .htaccess file (last line):

    ErrorDocument 404 index.php

    I also tried:

    ErrorDocument 404 http://www.mywebsite.com

    and

    ErrorDocument 404 http://www.mywebsite.com/index.php


    Well, nothing happens when you hit a 404 page...still get all those ads from hostgator and no re-direct.

    Any help would be highly appreciated.

    Thanks.
     
    cscorp, Apr 23, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could try this instead at the end of your .htaccess:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.html
    Code (markup):
     
    SmallPotatoes, Apr 23, 2009 IP
  3. micksss

    micksss Notable Member

    Messages:
    4,427
    Likes Received:
    268
    Best Answers:
    1
    Trophy Points:
    285
    #3
    This is what I do with my sites on hostgator for 404 pages.

    Put this line in my .htaccess file:
    Errordocument 404 /404.html
    Code (markup):
    Then created a file called 404.html with this code:

    <html>
    <head>
    <script type="text/javascript">
    <!--
    window.location = "http://www.mywebsite.com"
    //-->
    </script>
    </head>
    <body>
    </body>
    </html>
    Code (markup):
    Best of luck :)
     
    micksss, Apr 23, 2009 IP
  4. cscorp

    cscorp Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you guys are awesome...i will try each one and post what happens...
     
    cscorp, Apr 25, 2009 IP