View Full Version : How to set up Generic ErrorDoc pages...403, 404...etc
liejian
03-04-2003, 10:56 AM
Hi Does anyone know how to set up generic ErrorDoc pages...403, 404...etc?
I couldn't find it in any of the postings.
Thanks,
LJ
To create your own error documents
Add the following to the .htaccess file replacing the italicized text with the exact path to, and filename of your error doc.
ErrorDocument 400 /path/to/document_name.html
You can also do this for other error types like so:
ErrorDocument 401 /path/to/document_name.html
ErrorDocument 403 /path/to/document_name.html
ErrorDocument 404 /path/to/document_name.html
ErrorDocument 500 /path/to/document_name.html
Error Types:
400: Request Error (browser header probs or the like)
401: Authorization Required
403: Forbidden
404: File Not Found (user asked for non-existant file)
500: Server Error (bad script or something of that nature)
liejian
03-05-2003, 05:52 PM
Sorry, Nick. I didn't know the forums had a search capability. I used it and found multiple postings on this already. Won't happen again. :wink:
rizzay
09-06-2003, 01:23 PM
Hey guys, I've try implemeting personalized error documents and I can't get it to work in my .htaccess. I've updated my .htaccess file in my main dir to read:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+)?rizzay.com [NC]
RewriteCond %{REQUEST_URI} !^/hotlink.jpg [NC]
RewriteRule [^/]+.(gif|jpg|GIF|JPG)$ http://www.rizzay.com/hotlink.html [R,L]
Options -indexes
ErrorDocument 401 /var/www/html/403error.html
ErrorDocument 403 /var/www/html/403error.html
But I can't get these to appear when someone types in a file that's not there. Could someone give me a hand?
Thanks,
Mark
Hello Rizzay
http://wsabstract.com/howto/htaccess2.shtml
I have found that page to be a big help on .htaccess files
rizzay
09-06-2003, 05:38 PM
Hey Nick,
Thanks for the respose. I read through that page and it's similar to Joe's documentation here: http://www.hostpc.com/phpbb/viewtopic.php?...hlight=htaccess (http://www.hostpc.com/phpbb/viewtopic.php?t=147&highlight=htaccess). I used Joe's when writing my .htaccess file.
I'm still getting "Page cannot be found" for HTTP 404 - File not found
Internet Explorer errors instead of my custom page.
I've done the code with varying paths and even the full path with http:// with no success. Any other ideas?
Thanks,
Mark
bluesguy
09-07-2003, 02:33 AM
Do you have an ErrorDocument 404 line in your htaccess file?
rizzay
09-07-2003, 02:58 PM
Hey Bluesguy,
This is what is in my .htaccess file in my main /var/www/html/ directory:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+)?rizzay.com [NC]
RewriteCond %{REQUEST_URI} !^/hotlink.jpg [NC]
RewriteRule [^/]+.(gif|jpg|GIF|JPG)$ http://www.rizzay.com/hotlink.html [R,L]
Options -indexes
ErrorDocument 400 /var/www/html/generalerror.html
ErrorDocument 403 /var/www/html/403error.html
ErrorDocument 404 /var/www/html/404error.html
ErrorDocument 500 /var/www/html/generalerror.html
You can see the error docs by typing in http://rizzay.com/404error.html but if you type in http://www.rizzay.com/stuff.html (a file that is not there) you get the generic 404 error page.
UPDATE: If I try to access a file with a folder in my main (http://www.rizzay.com/photos/) directory I get:
Forbidden
You don't have permission to access /photos/ on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
--------------------------------------------------------------------------------
Apache/1.3.27 Server at www.rizzay.com Port 80
Does this have to do with permissions or something?
Thanks for your help!
Mark
Hello Mark
in ensim if you have a directory without an index.html file you will get a forbidden page
you can use an .htaccess to use a different page... index.php main.html or whatever you want to use or you can do a directory listing
rizzay
09-08-2003, 12:29 AM
Hey Nick,
Thanks for that info, but my main problem is the that I can't get the cutomized error documents to appear after setting the .htaccess file. Your explination about the directory error makes sense but I expected to see my customized error page instead of the generic page. I've read through the documentation and setup my .htaccess file and instructed but it still does not work as expected. Any ideas?
Thanks for you help,
Mark
Options +FollowSymLinks
ErrorDocument 400 /generalerror.html
ErrorDocument 403 /403error.html
ErrorDocument 404 /404error.html
ErrorDocument 500 /generalerror.html
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+)?rizzay.com [NC]
RewriteCond %{REQUEST_URI} !^/hotlink.jpg [NC]
RewriteRule [^/]+.(gif|jpg|GIF|JPG)$ http://www.rizzay.com/hotlink.html [R,L]
Options -indexes
Ok Mark..fixed
just /filename.html
not /var/www/html/filename/html
rizzay
09-08-2003, 02:30 AM
Hi Nick,
Thanks for your response. I changed the file as you suggested but now I get nothing if I type in an incorrect direct link (eg. http://rizzay.com/stuff.html) This file does not exist so I would expect to see my customized 404 error document but nothing happens. It's weird 'cause now I don't even get the microsoft error document for a bad file name.
P.S. I think I owe you and Joe a beer or two for your assistance!
Thanks,
Mark
Hello Mark,
What did you change? I had already edited your .htaccess file for you. It is still working for me. Trying clearing out your cache and retry the link to stuff.html
rizzay
09-08-2003, 01:50 PM
Thanks Nick. I now see the correct error page.
-Mark
flyer
10-12-2003, 01:25 PM
Rizzay,
Did you change your error handling? When I enter your nonexistent page name, I just get the standard screen for the 404 error. But I know your friendlier error page exists because I get it if I enter its name, which users obviously won't do.
rizzay
10-13-2003, 03:12 PM
Hi
Yes, I have been playing around with my error handling and have disabled it while testing.
Thanks,
Mark
mikeeve
10-16-2003, 03:05 PM
:oops:
I tried to view the default error messages for 401-405. I clicked on 'view' and for each message, I received a '404' error message. I thought, "Hmm, the default error messages are all set to 404". Now I realize that there are no default error messages! That's what the 404 was trying to tell me. (Stop laughing, it is a little confusing!)
Powered by vBulletin™ Version 4.0.3 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.