how to show 'page not found' if php page do not exist

Discussion in 'HTML & Website Design' started by greentree, Jun 25, 2008.

  1. #1
    I used the php tag to show some posts from my blog into a php page on the main folder. The blog is located at www.domain.com/wordpress
    The main folder is www.domain.com

    The php page is named as index.php If I type in inde2x.php, that page show my blog. It doesn't show a page not found error.

    How do I set this so that if I type in inde2x.php or any php page that isn't in my folder, it show a page not found?
     
    greentree, Jun 25, 2008 IP
  2. jammy467

    jammy467 Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    404 error. probably need to look at ht.access folder.

    Look for how to set up 404 errors on google.

    Tim
     
    jammy467, Jun 25, 2008 IP
  3. q7m

    q7m Well-Known Member

    Messages:
    1,178
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    1
    #3
    Create a custom error page and then add the following line of code in .htaccess:
    
    ErrorDocument 404 http://www.domain.com/404.php
    
    Code (markup):
     
    q7m, Jun 25, 2008 IP
  4. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It's possible that your host has previously setup your .htaccess file to load 404.htm or some other file type. Drop in 404.html in your root directory and try it out.
     
    steelfrog, Jun 25, 2008 IP
  5. greentree

    greentree Active Member

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #5
    The ErrorDocument given in the post didn't work. It probably didn't work because of the wordpress. I pay for my own hosting so I manually install my wordpress on my website.

    What else could I try?
     
    greentree, Jun 25, 2008 IP
  6. coolguy2006delhi

    coolguy2006delhi Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    Customizing Your 404 with Apache

    Create a file called .htaccess in the root directory of the server (the one you refer to as '/') and enter your error handlers in the following format, one per line:

    ErrorDocument [3-digit code] [action]

    For example, you can point to a custom 404 page like this:

    ErrorDocument 404 /errors/custom404.html

    You can also simply have it display some other text:

    ErrorDocument 404 "Sorry, this page doesn't exist.

    Make sure you begin the text with a quote (").
     
    coolguy2006delhi, Jun 26, 2008 IP
  7. greentree

    greentree Active Member

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #7
    I found a solution to this problem. It was the wordpress preventing the ErrorDocument from working in the htaccess file so I moved the htaccess file containing the wordpress stuff to the folder the wordpress is in. And then I put the ErrorDocument in the empty htaccess in the root folder, and it worked. My error php page even show up in IE when the wrong url is typed. It isn't going to work if it is place in the same htaccess that contain the wordpress stuff so the wordpress stuff have to have it own htaccess in it own folder.
    At least now the ErrorDocument work.
     
    greentree, Jun 26, 2008 IP