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.

Help with 404 pages!

Discussion in 'Search Engine Optimization' started by noxious, Jul 12, 2007.

  1. #1
    Well after a week of my site being opened, i decided to remove the shitty default host gator one. i googled for about 10mins, trying to find a 404 source that could give me the apache error, and then redirect in 10 seconds. i found someome post th apache source, but im having trouble with it cause it says
    if the directory is like /sdsaodsakd

    this is the code i have

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>404 Not Found</TITLE>
    </HEAD><BODY>
    <H1>Not Found</H1>
    The requested URL / was not found on this server.<P>
    <P>Additionally, a 404 Not Found
    error was encountered while trying to use an ErrorDocument to handle the request.
    <HR>
    <ADDRESS>Apache/1.3.37 Server at SERVER.TLD Port 80</ADDRESS>
    </BODY></HTML>
    <!-- 
                                                                                                                                                                                                                   
    --> 
    
    <!-- 
         
    --> 
    
    Code (markup):
    id like to have it redirect after 10 seconds and for it to display the correct directory. +rep and love for whoever helps me fix this lol
     
    noxious, Jul 12, 2007 IP
  2. Daudulus

    Daudulus Member

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Add this code between your <head>-tags:
    <META http-equiv="refresh" content="10;URL=yourURL">

    Replace yourURL with the link to your directory.
    As an example:
    http://www.yoursite/yourdirectory

    The 10 represents in how many seconds the visitor gets redirected.

    I would consider a permanent 301 redirect because it's more search engine friendly.
     
    Daudulus, Jul 12, 2007 IP
  3. noxious

    noxious Peon

    Messages:
    362
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok, how would i go about doing that?
     
    noxious, Jul 12, 2007 IP
  4. Daudulus

    Daudulus Member

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    In php:

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.yourdomain.com/directory");
    ?>

    In .htaccess:

    Redirect 301 /oldlocation http://www.yourdomain.com/newlocation

    Hope this helps. :)
     
    Daudulus, Jul 12, 2007 IP
  5. oseymour

    oseymour Well-Known Member

    Messages:
    3,960
    Likes Received:
    92
    Best Answers:
    0
    Trophy Points:
    135
    #5
    I would go with the .htaccess solution that daudulus posted above...It is the the most SEO friendly
     
    oseymour, Jul 12, 2007 IP
  6. noxious

    noxious Peon

    Messages:
    362
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    my site is new and doesn't (or shouldn't) have any broken pages. i'm just looking for a 404 redirect with the correct apache code, i guess ill use 301 in the future if i move sutff
     
    noxious, Jul 12, 2007 IP
  7. Daudulus

    Daudulus Member

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #7
    Insert the following code in your .htaccess:
    ErrorDocument 404.html

    Then create a 404.html where you insert the code you mentioned in the first post and add the metatag which I have given to you.
    Can I get my rep now please. :) :p
     
    Daudulus, Jul 12, 2007 IP
  8. noxious

    noxious Peon

    Messages:
    362
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    noxious, Jul 12, 2007 IP
  9. ewc21

    ewc21 Peon

    Messages:
    455
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ewc21, Jul 12, 2007 IP
  10. Daudulus

    Daudulus Member

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #10
    Now I begin to understand a bit more what you want.

    Of course you get this error because it's in your plain HTML code, so I don't understand what kind of error text you expect then. Change the '/' just in '/wrongdirectory' and then you will get the right error message. But this is static and doesn't make any sense then.

    If you want it dynamic so it changes every time to the name of the directory which isn't found. Then I would use PHP to get all text after the domainname. Put this PHP-code instead of the '/' after The requested URL:

    <?php
    echo $_SERVER['PHP_SELF'];
    ?>

    There's a possibility it just shows the name of you error document. Just try if this works. I hope your server supports PHP and you know how to handle with it. Don't forget to change the extension to .php. Don't forget to change the redirect to the error page to 404.php instead of 404.htm .

    You say you want to display the correct directory by redirecting to it after 10 seconds. I already mentioned the metatags which you have to add.

    But I think you can read what you really want here:
    http://www.onlamp.com/pub/a/onlamp/2003/02/13/davidsklar.html
     
    Daudulus, Jul 13, 2007 IP