.htaccess question

Discussion in 'Apache' started by Amilo, Jun 18, 2007.

  1. #1
    I have a site that I have updated with new content and new pages.

    Around 20 pages are now gone but still show up in google.

    Can somebody tell me how to redirect all these lost pages to my main index page please...
     
    Amilo, Jun 18, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Try with this:
    
    ErrorDocument 404 /index.html 
    
    Code (markup):
    Use your own homepage: index.php, index.htm, ...
     
    ajsa52, Jun 18, 2007 IP
    Amilo likes this.
  3. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks ajsa52 green rep added...
     
    Amilo, Jun 19, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That doesn't just send your old pages to the index, it sends everything that should generate a 404 error to the index page - and there's a good reason for sending back a 404 error instead of another page. It also doesn't redirect to the index.html, it shows the index.html page as if it were the requested page, so there's a bit of duplicate content there..

    Assuming you don't have a robots.txt or favicon.ico, whenever these get requested, instead of a usual 404 response you'll be sending back a 200 and the search engine will try and interpret your index page as a valid robots.txt file (which will obviously cause it problems) and browsers will try and use your index page as the icon, which obviously won't work either. Above all, it's a massive waste of bandwidth.

    Even if you do have these files, it's generally not a good idea to use your index page as the 404 document unless you have a reason. If it's only ~20 pages, you'd be better off manually 301 redirecting each to either a corresponding new page or the index page.

    Redirect /path/to/old.page http://url.to/new.page
    Code (markup):
     
    rodney88, Jun 19, 2007 IP
  5. Amilo

    Amilo Peon

    Messages:
    624
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Rodney that makes sense.
    I will give over an hour or 2 later today and redirect the lost pages the way you have shown me.
     
    Amilo, Jun 19, 2007 IP
  6. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #6
    rodney, even though it shows the index page as the 404 page, Google and other bots can still recognise that page resulted in a 404 so no duplicate content issues should arise.

    That being said, 404 pages are useful. So instead of using your index page for 404 errors, just keep the normal 404 page and Google will eventually pull the sites out of the index next time it tries to crawl the site.

    And for now, how about have a custom 404 page and have a script that checks the request to see if it was one of the deleted pages and just inform the user that it has been deleted with a link to the index/related pages.
     
    krt, Jun 19, 2007 IP
  7. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Whenever I use custom error documents on my server, I have to manually send the 404 status code with a php header, otherwise it sends 200. I assumed that was the default behaviour but the manual makes no mention of it so I guess I need to look into that and see what's wrong. So yeh, ignore duplicate content, my mistake.
     
    rodney88, Jun 19, 2007 IP