Anybody knows how to redirect all the invalid links to the home page?

Discussion in 'PHP' started by topdaytrader, Aug 28, 2008.

  1. #1
    topdaytrader, Aug 28, 2008 IP
  2. rcadble

    rcadble Peon

    Messages:
    109
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Simple. Edit .htaccess:

    ErrorDocument 404 /index.php
    Code (markup):
     
    rcadble, Aug 28, 2008 IP
  3. topdaytrader

    topdaytrader Active Member

    Messages:
    933
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    It'll only show the home page, but it won't redirect the link to the home page. It still shows the invalid link.

     
    topdaytrader, Aug 28, 2008 IP
  4. topdaytrader

    topdaytrader Active Member

    Messages:
    933
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Anybody knows how?
     
    topdaytrader, Aug 29, 2008 IP
  5. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ask your webhosting service, they may allow a custom 404 error page, this will not redirect, but show the home page at the invalid url.
     
    Ilyes, Aug 29, 2008 IP
  6. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Or, I found that, you may test it and tell us the result.

    Change:

    ErrorDocument 404 /index.php

    To

    errorDocument /index.php

    I'm not sure about. I found it here, just try it !
     
    Ilyes, Aug 29, 2008 IP
  7. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Go into your .htaccess file and change it to
    ErrorDocument 404 /error.php
    Code (markup):
    Then in error.php have
    <?php
    header('Location: /index.php');
    PHP:
     
    JAY6390, Aug 29, 2008 IP
  8. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This will redirect him, he want to stay in the same page, try solution in my previous post :)
     
    Ilyes, Aug 30, 2008 IP
  9. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Actually he didn't...
     
    JAY6390, Aug 30, 2008 IP