SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: error pages

  1. #1
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy error pages

    How can I create error pages on my site?

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your host Apache run or IIS and do you have control of the setup files/conf files on your server. ...
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you're running on Apache, just add this line to httpd.conf:
    Code:
    ErrorDocument 404 /missing.html
    #  to redirect to local URL /missing.html
    where missing.html is the document you want to redirect to in a 404 error... you can substitute 404 for the other error codes too...

  4. #4
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might like to add a few other errors as well like 500 (internal server error) and a few others...

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In my experience, Apache tends to ignore 500 ErrorDocument commands that are in .htaccess files

    Sean
    Harry Potter

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

  6. #6
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im using Apache and running php nuke. Will the 404 error code still work? So I need to add the code to the httpd.conf file then make a missing.html file?

  7. #7
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, thats it!
    I believe that sets the error page globally though, if you just want to change it for your site, you should use the .htaccess file , within your site's directory

  8. #8
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok this is what I see in the access file -

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName digitalrampage.com
    AuthUserFile /hsphere/local/home/path/to/_vti_pvt/service.pwd
    AuthGroupFile /hsphere/local/home/path/to/_vti_pvt/service.grp

    Where do I add it? Do I remove everything in that file then put the code in? Do I have to make a missing.html file for every error? How is it going to know which error file to goto?
    Last edited by X01; Feb 17, 2002 at 19:46.

  9. #9
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, leave what is already in there (don't want to break anything ) and just add your extra lines in there.

    You only have to add an arror page for common errors (like 404, etc) and yep, you'll have to make your error page still (call it whatever you want BTW).

    Theres a nice article on htaccess here

  10. #10
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I made and uploaded my missing.html file and edited the .htaccess file.

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName digitalrampage.com
    AuthUserFile /hsphere/local/home/path/to/_vti_pvt/service.pwd
    AuthGroupFile /hsphere/local/home/path/to/_vti_pvt/service.grp

    ErrorDocument 404 /missing.html
    # to redirect to local URL /missing.html

    But it doesnt worky both the .htaccess and missing.html are in the root folder.

  11. #11
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by X01
    Where do I add it? Do I remove everything in that file then put the code in? Do I have to make a missing.html file for every error? How is it going to know which error file to goto?
    you can simply add it to the end of the file if you can't find the section for it...

    as for the 2nd question: missing.html is simply a dummy name... you can replace it with the filename of the file you want Apache to serve when Error XXX occurs... a good way would be:
    Code:
    ErrorDocument 404 /404.html
    ErrorDocument 500 /500.html
    and so on...

    that's how Apache knows which file to go to... it isn't capable of "guessing" the file you want if you don't specify the exact error page

  12. #12
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by redemption

    you can simply add it to the end of the file if you can't find the section for it...

    as for the 2nd question: missing.html is simply a dummy name... you can replace it with the filename of the file you want Apache to serve when Error XXX occurs... a good way would be:
    Code:
    ErrorDocument 404 /404.html
    ErrorDocument 500 /500.html
    and so on...

    that's how Apache knows which file to go to... it isn't capable of "guessing" the file you want if you don't specify the exact error page
    Ok so I can name the file 404.html? Im confused about this part -

    ErrorDocument 404 /missing.html
    # to redirect to local URL /missing.html



    Do I just need to put the ErrorDocument # /filename.html part in the htaccess file?

    After I get this working, it should display the error page if I type domain.com/eralkdjafou? Or does it have to be .htm or something?
    Last edited by X01; Feb 18, 2002 at 04:15.

  13. #13
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by X01

    After I get this working, it should display the error page if I type domain.com/eralkdjafou? Or does it have to be .htm or something?
    Code:
    ErrorDocument 404 /filename.html
    is all you need to add for a redirection of a 404 error to the file "filename.html"...

    and yes, you can replace it doesn't only have to be .html... it can be .php or .txt or even .jpg so long as that's the file you want your user will get upon the error...

  14. #14
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks but its not working.. I will ask my host whats wrong


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
  •