how to redirect 404 error to homepage

Discussion in 'General Scripting Chat' started by newkid..., Mar 26, 2010.

  1. newkid...

    newkid... Jr. VIP Jr. VIP

    Joined:
    Jan 13, 2010
    Messages:
    1,119
    Likes Received:
    604
    Location:
    Planet Earth
    Home Page:
    Today I removed 6000 pages from my autoblog (which is still giving me traffic) but I had a remove it for some reason.

    Now I need to redirect all 404 error to homepage. Trying to do so by modifying .htacess but its just not happening.

    I added ErrorDocument 404 /index.php to .htaccess but it is not handling the error.

    For your info, I am using thesis theme.. ANY QUICK ADVISE

    NEED SOME URGENT SOLUTION. Thanks in advance
     
  2. homenet

    homenet Senior Member

    Joined:
    Jan 5, 2009
    Messages:
    800
    Likes Received:
    349
    Location:
    Dimension X
    Does your host allow custom 404 pages? If so then have a page called error.php and have this as the code:

    <?php

    header( 'Location: http://www.yourdomain.com/index.html' ) ;

    ?>

    Then upload error.php and select it as your custom 404 page.

    Obviously you will need the change the address in the code ive given you.
     
    • Thanks Thanks x 1
  3. newkid...

    newkid... Jr. VIP Jr. VIP

    Joined:
    Jan 13, 2010
    Messages:
    1,119
    Likes Received:
    604
    Location:
    Planet Earth
    Home Page:
    @ homenet. Thanks what I did is I copied your code and named it 404.php and replaced this file with original 404.php... and it worked like a charm. Hope will not have any negative impact on seo
     
  4. homenet

    homenet Senior Member

    Joined:
    Jan 5, 2009
    Messages:
    800
    Likes Received:
    349
    Location:
    Dimension X
    No probs.

    No I cant see it having any effect at all on your SEO.