Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2002
    Posts
    85

    Angry .htaccess and 404.shtml (under CPanel)

    I'm wondering how CPanel custom 404 error pages are implemented technically. I suppose, there should be a line in the .htaccess file, something like this (can't remember exactly):

    ErrorRedirect 404 http://www.mydomain.com/404.shtml

    And the CPanel should add this line automatically. But the problem is that I simply can't find the .htaccess file! I tried to find it using the File Manager in the CPanel, but found nothing. I also tried to logon via SSH client (putty), browsed through all the folders, and again didn't find it.

    So how are the CPanel 404 redirects implemented if there's no .htaccess file? Or maybe I should look for it somewhere else? Thanks

  2. #2
    i thought you can just input html in one of the sections of cpanel which allows you to edit the error pages ?

  3. #3
    Join Date
    Oct 2002
    Posts
    85
    Yes, I can use the CPanel 'Custom Error Pages' section to do that. All of my error pages are currently set up this way, but I've run into a problem: These pages are shown incorrectly when a user requests a missing file from a subfolder, not from the root folder of the site -- pictures and CSS aren't visible, and the page looks horrible. This happens because all paths to pictures and CSSs in my 404.shtml are relative, not absolute.

    I don't want to use absolute paths to pictures in the 404.shtml, and would prefer to simply redirect it to another page, say 404err.htm, which could be placed in the root site folder.

    Currently, I'm redirecting from their default 404.shtml to my own error page using the meta refresh tag with no timeout, but I think there should be a way to do this from the server side (using .htaccess) -- it should work faster than the meta-refresh.

    Please, please help me find that .htaccess file!

  4. #4
    Join Date
    Nov 2001
    Posts
    857
    The information isn't stored in the .htaccess file. It is stored in /usr/local/apache/conf/httpd.conf using alias tags.

    The best way to do it is to set absolute links ie. <img src="/images/image.gif"> instead of <img src="images/image.gif">

    Regards,
    Michael
    <?
    header("Location: http://www.hostevolve.com/");
    ?>

  5. #5
    Join Date
    May 2001
    Location
    HK
    Posts
    3,077

    Smile

    Easy,

    Just create your own .htaccess file for errordocs from SSH or upload it with FTP.

    Code:
    ErrorDocument	404	/my_404.html
    #Note, the above path is not the full server path...

    If you are looking for that .htaccess, just write a script to search for .htaccess under your home directory OR find your file from SSH... i am sure there is a command to do that...

  6. #6
    Join Date
    Oct 2002
    Posts
    85
    >The information isn't stored in the .htaccess file.
    >It is stored in /usr/local/apache/conf/httpd.conf using alias tags.

    Michael, can I override these settings using .htaccess placed in the root site folder? I'm concerned that doing this could break CPanel's own 404 settings -- should I worry?

  7. #7
    but why go through all this trouble when actually cpanel has it for you to just enter html codings ?

  8. #8
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    20,906
    Originally posted by michaeln
    The best way to do it is to set absolute links ie. <img src="/images/image.gif"> instead of <img src="images/image.gif">
    Those are not absolute links.

    Document relative: "../images/image.gif" or "images/image.gif"

    Root relative: "/images/image.gif"

    Absolute links would be "http://www.domain.com/images/image.gif".
    Hope that helps.

Related Posts from theWHIR.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •