Custom HTML 404 page

Discussion in 'Apache' started by ForumJoiner, Apr 11, 2007.

  1. #1
    My host allows me a custom HTML 404 page. I want to display a nice error message, along with the name of the page that generated the message. If the page has html extension, I can't use php. Is any workaround to make Apache to process a php code <?php ... ?> inside a page that has html extension?
     
    ForumJoiner, Apr 11, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The easiest solution is to not use your hosts control panel but do it yourself - create a .php error page and specify that as the error document via .htaccess:
    ErrorDocument 404 /404.php
    Code (markup):
    That will send all 404 requests to a script called "404.php" in the root of your domain.
     
    rodney88, Apr 11, 2007 IP
  3. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #3
    If I have only one .htaccess file, in the root of the domain it should handle only the 404 for the root, like:
    xxx.com/badlink.php
    or all the 404s, even for:
    xxx.com/test/badlink.php?
     
    ForumJoiner, Apr 11, 2007 IP