How to hide 404 not found?

Discussion in 'PHP' started by mark103, Sep 24, 2010.

  1. #1
    Hi guys,

    I did a little research, but I cannot be able to find the answer. So I need your help. How I could hide the 404 not found that if the server is down or if the file get deleted?

    Here it is the php that I am using:

    
    <?php
    	require_once('auth.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Member Index</title>
    <link href="loginmodule.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
    Home | <a href="home.php">My Account</a> | <a href="logout.php">Logout</a>
    ?>
    
    PHP:
    If it impossible to hide the 404 not found error, then I have got another question: how could I hide the actual url in the address bar by using the script on above?



    Hope you can help!


    Thanks,
    Mark
     
    mark103, Sep 24, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Lookup .htaccess error 404
     
    danx10, Sep 24, 2010 IP
  3. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #3
    I would use htaccess

    ErrorDocument 404 /index.php
    Code (markup):
    what that does is redirect to the index page if there are any 404's.
     
    mcfox, Sep 24, 2010 IP
  4. mark103

    mark103 Active Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Thanks for your advice guys, I cannot find htaccess in my control panel. Do you know where I could find them?
     
    mark103, Sep 24, 2010 IP
  5. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #5
    Well it depends who your hosted with and also whether it is Apache or not (htaccess is an Apache directive) but it should be in the root of your domain. You should be able to see it if you ftp to your site. Assuming your server uses htaccess and it doesn't exist in the root area of your site then all you need do is create one. Create a file called htaccess.txt in notepad, upload it to root then rename it to .htaccess, being careful to prepend it with the dot.
     
    mcfox, Sep 24, 2010 IP