View Full Version : Custom error pages per site
Whitesell 03-28-2002, 09:50 AM Hi All,
I found this at raqsetup.com:
---------------
How do i change the default error page messages?
Example: ErrorDocument 404 /404.html
Open Notepad.
Type this (only):
ErrorDocument 404 /404.html
Upload it in ASCII mode (very important!!!) to your web
directory for the domain. Create a HTML file called 404.html
(put something in the HTML file like "This worked!").
Upload this into the web directory of the site as well (ASCII mode).
Test by calling a file that you know doesn't exist (jkhdj.html).
If this worked then you can put whatever you would like in the 404.html
and you can do the same for the other error pages.
(Note: if the above does not work try typing in the full url
ex. ErrorDocument 404/http://www.raqsetup.com/404.html)
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html
------------
This looks like a great way to allow different sites to have their own custom error pages - but there's one thing missing.
What do you name the text file containing:
ErrorDocument 404 /404.html
That gets uploaded to the sites root web directory?
Thanks,
Jim Whitesell
dutchie 03-28-2002, 10:23 AM call it .htaccess
dlyles 04-03-2002, 09:03 PM I tried that, and my ftp program is not letting me upload the .htaccess page. Do I have to upload a diff way?
AMJones 04-03-2002, 09:44 PM Hm. What FTP program? Sounds like you should switch ;p
Try uploading it as a different filename, then renaming it, perhaps?
dlyles 04-03-2002, 10:01 PM I'm using cute FTP. I renamed it, uploaded it than renamed it. After I renamed it, it disappeared. ?????
Whitesell 04-03-2002, 10:54 PM dlyles,
Any file name that begins with a period like .htaccess won't show up using ftp but it will be on the server. You'll have to go in via telnet or SSH to see it, delete it or change permissions.
Regards,
Jim Whitesell
dlyles 04-03-2002, 11:31 PM Ok, that's good to know. Than for some reason it's not working. I typed ErrorDocument 404 /404.html and nothing as well as ErrorDocument 404 /http://www.domainname/404.html
blacknight 04-04-2002, 01:19 AM Instead of trying to load the error document try loading a page that doesn't exist. That should load the 404 document etc., etc.,
On the issue of .ht* files ....
Using SSH you need to list them by ls -l .h* or whatever. If you do the standard ls , they will remain invisible.
dlyles 04-04-2002, 01:27 AM I see it will I telnet in. I was trying to get it by typing a page that doesn't exist, but with no luck.
iplexx 04-04-2002, 04:02 AM did you also upload a 404.html into /web?
otherwise, if you login via ssh and do a
tail /home/log/httpd/error
you'd should see the reason why it doesn't work
LinuXpert 04-04-2002, 04:45 AM Open Notepad and type:
ErrorDocument 404 /error.html
Save it as htaccess.txt
Now create a HTML page call error.html
Upload both files to your root directory in ASCII mode
Rename htaccess.txt to .htaccess
Test by calling a file that you know doesn't exist (http://yoursite.com/jkhdj.html), the error.html will be displayed in your browser.
Some FTP clients do not display files begin with a dot like .htaccess. I know SmartFTP can, you can try it at http://smartftp.com
SI-Chris 04-04-2002, 07:33 AM Originally posted by Whitesell
dlyles,
Any file name that begins with a period like .htaccess won't show up using ftp but it will be on the server. You'll have to go in via telnet or SSH to see it, delete it or change permissions.
Regards,
Jim Whitesell
In CuteFTP choose Edit > Filter..., then click the check box for "Enable remote filters (Server applied filter)," then in the "Remote filters" text box enter: -a
Click OK and you'll be able to see .htaccess type files in CuteFTP.
dlyles 04-04-2002, 10:46 AM Ok, I've don all of that. I can see the file when I telnet in.
In CuteFTP choose Edit > Filter..., then click the check box for "Enable remote filters (Server applied filter)," then in the "Remote filters" text box enter: -a
I did this and I can't see any files listed in the web directory.
LinuXpert 04-04-2002, 11:05 AM Try SmartFTP (http://smartftp.com)
dutchie 04-04-2002, 01:35 PM If i wanted to change the default errorpage serverwide, would'nt it be easier to replace the current cobalt file ?
I guess its stored somewhere ?
ASPCode.net 04-04-2002, 04:18 PM Originally posted by dutchie
If i wanted to change the default errorpage serverwide, would'nt it be easier to replace the current cobalt file ?
I guess its stored somewhere ?
True. access.conf lets you accomplish this. IMHO error documents SHOULD be handled by access.conf in a shared hosting environment, not by .htaccess since .htaccess should only allow AuthConfig ( security reasons ).
So, this is how to do it:
pico /etc/httpd/conf/access.conf
Look for the directive
<Directory /home/sites/>
Add these lines just beneath it
ErrorDocument 400 /Error_Docs/400.html
ErrorDocument 401 /Error_Docs/401.html
ErrorDocument 403 /Error_Docs/403.html
ErrorDocument 404 /Error_Docs/404.html
ErrorDocument 500 /Error_Docs/500.html
ErrorDocument 501 /Error_Docs/501.html
ErrorDocument 502 /Error_Docs/502.html
ErrorDocument 503 /Error_Docs/503.html
Now each site could place their error files under their web/Error_Docs/400.html etc
D8Mike 04-04-2002, 11:51 PM How do I create a custom 404 error page?
To create a custom 404 error page, first create the error page and save it as "404.htm" or anything you wish. Next, open notepad and inside put this line:
ErrorDocument 404 /404.htm
Save it as ".htaccess" (without the quotes DON'T forget the period). Upload it to your /web directory in ASCII mode and upload the 404.htm file to the /web folder. You've just created your own 404 error page!
To view .htaccess files with ws_ftp just type -al in the blank box under MkDir on right side in the folder your .htaccess file is in.
dutchie 04-05-2002, 07:10 AM Look for the directive
<Directory /home/sites/>
Add these lines just beneath it
ErrorDocument 400 /Error_Docs/400.html
ErrorDocument 401 /Error_Docs/401.html
ErrorDocument 403 /Error_Docs/403.html
ErrorDocument 404 /Error_Docs/404.html
ErrorDocument 500 /Error_Docs/500.html
ErrorDocument 501 /Error_Docs/501.html
ErrorDocument 502 /Error_Docs/502.html
ErrorDocument 503 /Error_Docs/503.html
This would mean i have to create a directory on every existing site with these documents.
Cant i just place them somewhere central ?
so just put in the access.conf
ErrorDocument 400 /home/sites/home/web/Error_Docs/400.html
Or would this mess up ?
ASPCode.net 04-05-2002, 03:43 PM Originally posted by dutchie
This would mean i have to create a directory on every existing site with these documents.
Cant i just place them somewhere central ?
so just put in the access.conf
Or would this mess up ?
I kinda knew this would come up - but I was too lazy yesterday. I have solved it by modifying the default templates - that is files copied to each siteXX directory when a new site is created:
1. Upload your default error templates to a place like
/home/sites/home/temp/errordocs ( that is 400.html, 401.html etc )
mkdir /etc/skel/group/en_US/web/Error_Docs
chmod 664 /home/sites/home/temp/errordocs/*.html
cp /home/sites/home/temp/errordocs/*.html /etc/skel/group/en_US/web/Error_Docs
Now whenever you create a site through the Cobalt CP that directory will be created and all default files will copied.
dutchie 04-06-2002, 03:57 AM Thans ASPcode, but in the mean i found an even simpler method on WHT.
Replace the fileNotFound.html in the /usr/admserv/html/.cobalt/error/ and it will work instantly :)
i tried it on 2 raq3's and 2 raq4's and it worked perfectly, i think this is the most simple way to do it without editing any files.
|