The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

404.php instead of 404.shtml

Discussion in 'General Discussion' started by jamesbond, Dec 1, 2003.

  1. jamesbond

    jamesbond Well-Known Member

    Joined:
    Oct 9, 2002
    Messages:
    738
    Likes Received:
    1
    Trophy Points:
    18
    I tried saving a custom error page as 404.php, the page does get saved, but it doesn't work when I request a page that doesn't exist. ( I see the default server error page )

    I haven't been able to find out where the redirect to site's 404.shtml is being made (I guess when I change that to 404.php it would work)

    Anyone?
     
  2. Wallaby

    Wallaby Well-Known Member

    Joined:
    Aug 15, 2001
    Messages:
    131
    Likes Received:
    1
    Trophy Points:
    18
    The file needs to be shtml if you are using CPanel to set it up.

    You can include a php file in the shtml file, like this:

    <!--#include virtual="/error/404.php"-->

    where errror is a directory under public_html and 404.php is your php error file.

    Another way (if you are using certain bits of PHP that don't like to be wrapped by SSI) is to include an shtml file:

    <!--#include virtual="/error/404.shtml"-->

    and then put an .htaccess file into your error directory like this:

    <snip>
    RemoveHandler .shtml
    AddType application/x-httpd-php .shtml
    <snip>

    Apache will now think .shtml is php... :D
     
  3. jamesbond

    jamesbond Well-Known Member

    Joined:
    Oct 9, 2002
    Messages:
    738
    Likes Received:
    1
    Trophy Points:
    18
    Thanks Wallaby,

    I added the lines to the .htaccess file and it works :)
     
  4. nitaish

    nitaish Well-Known Member
    PartnerNOC

    Joined:
    Jan 6, 2006
    Messages:
    123
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Mulund, India, India
    What do you mean by <snip>?
     
Loading...

Share This Page