SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Enthusiast Ude's Avatar
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I make my own "http 404 - File not found" page?

    Hi there,

    like the subject already asks, what kind of document I should place in my website so that whenever a surfer would normally find himself in front of the basic "404" page, an alternative self-made page would load instead (with a nice picture and some more informative text for instance)?

    Bonus question: how can I make a web folder deny straight access to itself ("access forbidden")?

    Thanks in advance.
    ~~~ude

  2. #2
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know which Web server you're using? It's quite important to know.

  3. #3
    SitePoint Enthusiast Ude's Avatar
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a unix server, a linux one I'm told. Is this specific enough?
    ~~~ude

  4. #4
    SitePoint Addict psychedelic's Avatar
    Join Date
    Feb 2002
    Location
    Boston
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're running Linux with Apache do this:

    Make a .htaccess file with the following code

    Code:
    ErrorDocument 404 /error/404.html
    ErrorDocument 403 /error/403.html
    Options -indexes
    The 3rd line will make any directory without the default index.html file a 403 "forbidden" directory.

    Create a directory called "error" in your parent directory of your site and put 2 files in there, 404.html and 403.html each for their respective errors.

    That's the basics of it.

    Make sure the file name has the period IN FRONT of "htaccess" so you get .htaccess

    and place this file in your parent directory.
    The Internet is prettier on a Mac.

  5. #5
    SitePoint Enthusiast Ude's Avatar
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code,

    I've now placed it in my web sites root folder and it redirects then now into my desired page if a 403 or 404 error occures, but if I add the third row "option" code, it denies all access any file, even root folder files which does have the index.html file.

    "HTTP 500 - Internal server error" it says.

    Btw, the server is Apache.
    ~~~ude

  6. #6
    Weird Little Girl Desdelena's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im not sure if its case-sensitive or not but try putting "-Indexes" instead. Also try setting a directory index.

    Code:
    DirectoryIndex index.html
    Add the filename.ext that you want to default load, I just used index.html as an example.

  7. #7
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if your host supports php, you can do the folowing:

    put this in your htaccess file [I'm giving you a one line example, add your 403,404, 500 errors accordingly]:

    ErrorDocument 401 http://www.YoUrSiTe.com/error.php?401


    and in your error.php file...write the following:

    PHP Code:
    <?
    $htm_401
    ="401.htm";  
    //add for others too - 403,404,500
    ?>

  8. #8
    SitePoint Enthusiast Ude's Avatar
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The server doesn't support php, as its a school server and it doesn't allow me to do such things for a reason.

    Actually, I played around with the code "Options -Indexes" and "DirectoryIndex index.html" and it didn't help (internal server error). So I guess I'm just not permitted to do such files on a school server.

    Well, I think its about time to get a proper domain if I'd like to use a tad more advanced features.

    Thanks anyway!
    ~~~ude

  9. #9
    SitePoint Member
    Join Date
    Jun 2002
    Location
    Pittsburgh
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you do the same thing if you are on an NT server?

  10. #10
    SitePoint Addict psychedelic's Avatar
    Join Date
    Feb 2002
    Location
    Boston
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you're on a Linux server? Are you running Apache?

    Do you have a control panel? Usually if you peruse through those things, they'll have a utility to make error pages for you.
    The Internet is prettier on a Mac.

  11. #11
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Operating System makes no difference, .htaccess is an Apache feature

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  12. #12
    SitePoint Enthusiast Ude's Avatar
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The server is as close an unix server can get (ssh login, total ascii interface, typing unix commands, etc.). The version string I got is "UNIX Type: L8 Version: SVR4". The Apache has a version tag of 1.2.6.

    Now my root directory has the natural public_html folder. I've placed the .htaccess file in both the root directory and public_html folder with the "internal server error" result.

    I don't know, maybe it's some restriction in the school server...
    ~~~ude

  13. #13
    Weird Little Girl Desdelena's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A school server? Hmm... are you allowed to use HTACCESS files on that server? You might want to ask someone, just incase.


Bookmarks

Posting Permissions

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