Click to See Complete Forum and Search --> : custom error messages per website
hoffa69
03-19-2003, 05:40 PM
In Apache I want to create custom error html pages for 401 errors.
I know how to do this for all websites, but I want to create custom ones for each website and am not sure how to do this.
clane
03-19-2003, 08:18 PM
I'm not sure if I understand your question, but I think all you need to do is create your custom error page using standard html:
<HTML>
<HEAD>
<TITLE>Put a title in here</TITLE>
</HEAD>
<BODY>
Put your custom error message, images or whatever in here
</BODY>
</HTML>
Then post that page to the home directory of the web site. Lets assume you called this file error401.html
Next create a file named .htaccess using a plain-text editor. (Note the period in front of the h). Use an editor that does not append its own suffix to the file name (such as Word for Windows that appends .doc to everything).
In that file put this line of text:
ErrorDocument 401 /error401.html
Hope this helps and works. If not, the advice was worth every penny you paid for it.....and not a penny more.
hoffa69
03-20-2003, 06:56 PM
Yes, I tried exactly that without any success. I have a working .htaccess file the authenticates users and I just cut and pasted the ErrorDocument 401 /error401.html
into that.
I guess I need to do some other things.
clane
03-20-2003, 07:44 PM
Just for the sake of trying..................
Can you create a new .htaccess file with just a single line of text in it:
ErrorDocument 401 /error401.html
and see if that works? I'm not a guru at these things, but maybe there is something else in the file that is keeping the custom message from working. It's just a SWAG, but simple enough to try. If that fixes it, then you can concentrate on what is in the original file that is keeping it from working. If it still doesn't work, then you can look elsewhere.
hoffa69
03-21-2003, 05:20 PM
Ok, I got it to work now. It appears that the ErrorDocument 401 /error401.html
has to be in root html folder and not in same folder as .htaccess.
hoffa69
03-21-2003, 05:22 PM
I'm just wondering now, if I want to create other error pages specific for each site, will I have to put .htaccess in all directories within my specific website in order to get them to work? There should be a way I can put all of the error page references in Virtualhost area for the specific site.
clane
03-21-2003, 08:17 PM
Are you saying that you put the .htaccess file in a different directory than the error401.html file?
I'm not using a custom 401 error document, but I am using a custom 404 error document. Both are in the same directory and it works.
hoffa69
03-21-2003, 09:48 PM
Yes, I have .htaccess in diferent directory than error document.
my root html page is /var/www/html, the secure folder is /var/www/html/secure, I put the .htaccess in the secure directory and error document in /var/www/html.
I guess if I want to have them in same directory, I'll have to put
ErrorDocument 401 /secure/error401.html instead of just /error401.html.