Help - Search - Members - Calendar
Full Version: How to Custom Error Pages new domains
The Planet Forums > System Administration > HOWTOs
slick
This will automaticly setup custom errorpages for new domains.
I used this dir as structure is setup.
NOTE: the pages wont work unless they are larger then 1kb

CUSTOM ERROR DOCS
cd /root
mkdir var
cd var
mkdir www
cd www
mkdir html
cd html
pico .htaccess
#Add the following
ErrorDocument 401 /error_docs/401.html
ErrorDocument 403 /error_docs/403.html
ErrorDocument 404 /error_docs/404.html
ErrorDocument 500 /error_docs/500.html
[ctrl x] Click Yes, then save
mkdir error_docs
cd error_docs
pico 401.html
#Add the Following
Add 401 html here
[ctrl x] Click Yes, then save
pico 403.html
#Add the Following
Add 403 html here
[ctrl x] Click Yes, then save
pico 404.html
#Add the Following
Add 404 html here
[ctrl x] Click Yes, then save
pico 500.html
#Add the Following
Add 500 html here
[ctrl x] Click Yes, then save
/etc/rc.d/init.d/httpd restart
chmod 0777 401.html
chmod 0777 403.html
chmod 0777 404.html
chmod 0777 500.html
cd /root
tar -cf virtDomain.tar var
cp virtDomain.tar /etc/appliance/customization/

UPDATED AND FIXED! No more ENSIM_DOMAINNAME problems.
Please note: Apache will ignore error pages less then 1 kb or something like that. To avoid this add a few lines of text 3-4 should do it or some html.
aussie
Lovely! Do you have a script that will allow me to setup

Formail
Counter
etc

During siterollout? So that i dont have to keep setting these up for every new user when a new account is created? If somebody has one id appreciate it very much.
Ric
The .htaccess ErrorDocument spec has always worked on our Sun without this but on our server here, this had to be added above the specs to make them work.

Options +FollowSymlinks

This looks like a great idea, do you know how you would apply it on a Plesk based system? I doubt if it is possible because one bad thing about Plesk is that the only template configuration it offers is for the DNS. I have thought about bash scripts to do some basic domain setup routines but Plesk is so picky when it comes to configs.

Rick
aussie
QUOTE
Originally posted by slick
This will automaticly setup custom errorpages for new domains.
I used this dir as structure is setup.
NOTE: the pages wont work unless they are larger then 1kb

CUSTOM ERROR DOCS
cd /etc/virtualhosting/templates/apache/var/www/html
pico .htaccess
#Add the following
ErrorDocument 401 /error_docs/401.html
ErrorDocument 403 /error_docs/403.html
ErrorDocument 404 /error_docs/404.html
ErrorDocument 500 /error_docs/500.html
[ctrl x] Click Yes, then save
mkdir error_docs
cd error_docs
pico 401.html
#Add the Following
Add 401 html here
[ctrl x] Click Yes, then save
pico 403.html
#Add the Following
Add 403 html here
[ctrl x] Click Yes, then save
pico 404.html
#Add the Following
Add 404 html here
[ctrl x] Click Yes, then save
pico 500.html
#Add the Following
Add 500 html here
[ctrl x] Click Yes, then save
/etc/rc.d/init.d/httpd restart
chmod 0777 401.html
chmod 0777 403.html
chmod 0777 404.html
chmod 0777 500.html
cd /etc/virtualhosting/templates/apache/
tar -cf virtDomain.tar var
cp virtDomain.tar /etc/appliance/customization/


My error docs have quite a few images associated? So one should move those to /images?

Why did you do this?
cd /etc/virtualhosting/templates/apache/
tar -cf virtDomain.tar var
cp virtDomain.tar /etc/appliance/customization/

I dont want the default ensim images rolled out to my sites because i have a my own index.html that gets sent. So if i remove the ensim images from /images dir the site doesnt get created. Anyone know how to remove ensim images before site gets created?
slick
Actually you dont have to do it liek that.
If you want goto like /home/admin
then
mkdir var
cd var
mkdir www
cd www
mkdir html
cd html
then you could do all adding pages and stuff here
cd /home/admin
then tar it normally.

Please explain
My error docs have quite a few images associated? So one should move those to /images?

I did this to tar the files in var
cd /etc/virtualhosting/templates/apache/
tar -cf virtDomain.tar var
cp virtDomain.tar /etc/appliance/customization/
every time a new domain is created ensim untars this file to new domains. you must add the dir var, www, html because ensim untars at the root dir.

also aussie if you need those scripts incorporated contact me.

RE above: for plesk, custom error pages automaticly come with it, Cool thing about plesk is it has a folder called .skel, locate it and your files to create new domaisn are located their, you can add and remove or edit them.
Ric
Thank you! I had to grep to find the default index page it puts up for new domains and I should have used common sense to go up a dir and see the rest. Why they don't have that info in the Plesk manual is beyond me, thanks again!

Second look: This is really nice, even the cgi-bin dir so I can install common scripts for automatic availability. The only problem I see is that scripts setup in the .skel dir would have to be able to use the IP address instead of the domain name.

Rick
aussie
QUOTE
Originally posted by slick
Actually you dont have to do it liek that.
If you want goto like /home/admin
then
mkdir var
cd var
mkdir www
cd www
mkdir html
cd html
then you could do all adding pages and stuff here
cd /home/admin
then tar it normally.

Please explain
My error docs have quite a few images associated? So one should move those to /images?  

I did this to tar the files in var
cd /etc/virtualhosting/templates/apache/  
tar -cf virtDomain.tar var  
cp virtDomain.tar /etc/appliance/customization/  
every time a new domain is created ensim untars this  file to new domains.  you must add the dir var, www, html because ensim untars at the root dir.

also aussie if you need those scripts incorporated contact me.

RE above: for plesk, custom error pages automaticly come with it,  Cool thing about plesk is it has a folder called .skel, locate it and your files to create new domaisn are located their, you can add and remove or edit them.


The problem i had with this setup is as follows. I have an index.html file in /etc/virtualhosting/templates/apache/var/www/html. If i do a tar -cf virtDomain.tar var from this dir it adds my index.html to the tar file and when its rolled out to the site the Ensim variable ENSIM_DOMAINAME is not replace with the actual domain name. Thats a big problem. This variable also need to be in our .htaccess file which is also not replaced with the domainname.
slick
aussie, actually it doesnt have to be in .htaccess
What i did is copy the index from /html to like /apche above /var. Then remove it and tar it, then copy the tar to the custom and return index.
Good point, the thign is, ensim untars after it creates main files. It replaces the index file with the one that went through the process of gaining its domain. The index in the tar replaces it and it doesnt go through the process of gaining its domain. Ill make a better how to soon.
Peakin
How will this affect existing hosted sites... will it clash with the existing .htaccess and error docs in place or will it only apply to new sites created from ensim ?

Cheers,

Peaks
foggy
QUOTE
Originally posted by aussie


The problem i had with this setup is as follows. I have an index.html file in /etc/virtualhosting/templates/apache/var/www/html. If i do a tar -cf virtDomain.tar var from this dir it adds my index.html to the tar file and when its rolled out to the site the Ensim variable ENSIM_DOMAINAME is not replace with the actual domain name. Thats a big problem. This variable also need to be in our .htaccess file which is also not replaced with the domainname.


Aussie, How do you correct the ENSIM_DOMAINMAME from appearing?

thanks
slick
The problem is in that directory the index.html file is the default page, however its placed before this tar is ran and overwrites the current index.html file that already got the DOMAIM_NAME changed to the real domain name. To fix this just make the directorys var/www/html in like /root or /home/admin and work from there.
doneright
I followed these instructions to setup the custom error pages and it did work. But I am experiencing the same problem that some others are having in which the actual domain name is not getting substituded into my welcome page anymore.

I read the last replying saying that in order to fix this, "... just make the directorys var/www/html in like /root or /home/admin and work from there". I don't understand what you mean by this. Can you give me more detailed instructions on how I can get the domain to be substituded into the welcome page again?

Thanks.
fulcan1
By setting up custom error pages, do customers then have the opportunity to change the error page or will it always be what I have set it to?

Thanks
doneright
Yes, your customers can simply edit the .html error files that are contained in the 'error_docs' folder. When you setup custom error pages as instructed in this thread, the error pages will reside on the customers server under the folder 'html/error_docs'.

Just so you know, I am still awaiting a solution to my previous post. I need to figure out a way for the 'ENSIM_DOMAINNAME' to be substituded with the correct domain. Remember that creating these custom error pages as instructed in this thread will disable the substituation of ENSIM_DOMAINNAME with the real domain in the default welcome page.
fulcan1
Another question if I may. If accounts have already been setup, what is the method to get the error_docs directory etc setup on all the existing accounts?

Thanks
d00der
Why would you tar this, arent "/etc/virtualhosting/templates/apache/var/www/html" the files that are copied by default when a new name is setup?
doneright
fulcan1:
I don't know any way to create these custom error pages on current sites except to create them manually by FTPing into the site.

Back to the main issue:
Only cetain files from "/etc/virtualhosting/templates/apache/var/www/html" seem to get copied such as index.html. Any other files that you create in this directory will not get copied over to the site because the system is not actually aware of these files.
phenx
QUOTE
Originally posted by doneright
fulcan1:
I don't know any way to create these custom error pages on current sites except to create them manually by FTPing into the site.

Back to the main issue:
Only cetain files from "/etc/virtualhosting/templates/apache/var/www/html" seem to get copied such as index.html.  Any other files that you create in this directory will not get copied over to the site because the system is not actually aware of these files.


stick the files you need for the temp files (i.e. images etc) on your host domain so they will always be there.
doneright
This will not work. Just so I understand what you mean, you are saying that I should place any files that I want transferred over to the new site on my main server under the directory "/etc/virtualhosting/templates/apache/var/www/html"? The system will not copy these files over automatically. It will only copy over the default files such as index.html, etc. I think I need to tell the system somehow that these other error files exist so it knows to copy them over whenever I create a new site.
phenx
QUOTE
Originally posted by doneright
This will not work.  Just so I understand what you mean, you are saying that I should place any files that I want transferred over to the new site on my main server under the directory "/etc/virtualhosting/templates/apache/var/www/html"?  The system will not copy these files over automatically.  It will only copy over the default files such as index.html, etc.  I think I need to tell the system somehow that these other error files exist so it knows to copy them over whenever I create a new site.


No, what i mean is modify the existing index.html to whatever you want it to be, but like the images and whatever other files on the template to your domain (i.e blahhosting.com) so the template will pull the images from say www.blahosting.com/ensimtemplate/blah.jpg etc.

You are correct, it will only copy over the index.html so you have to link the other files to an external place.
doneright
I don't have any images to copy over. I just need to copy over some .html files used for error pages (404, 500, etc). So what you have said is not a solution to my problem.
d00der
I've changed my defauly rollout pages, but i've noticed that the user pages are still the same, where are the files for those?

thanx icon_wink.gif
Ropey
QUOTE
Originally posted by doneright
Yes, your customers can simply edit the .html error files that are contained in the 'error_docs' folder.  When you setup custom error pages as instructed in this thread, the error pages will reside on the customers server under the folder 'html/error_docs'.

Just so you know, I am still awaiting a solution to my previous post.  I need to figure out a way for the 'ENSIM_DOMAINNAME' to be substituded with the correct domain.  Remember that creating these custom error pages as instructed in this thread will disable the substituation of ENSIM_DOMAINNAME with the real domain in the default welcome page.


the setup of new domains with the matching index.html page goes great, as i get all the pictures from this account from the main account, like http://mydomain.com/images/....
but ENSIM_DOMAINNAME is what it still says on each account and does not fill out the domain for me....anybody found a solution for this?

Ropey
slick
I guess you guys did not understand my solution to the problem of new domains saying ENSIM_DOMAINNAME instead of there domain name.
The problem is the directory i used in this tutorial. Theres a file called index.html the main index file for new domains. This is the process for new domains.
1.Setups services
2.Copys the index file and images from the template folder to new domain.
3.Server changes ENSIM_DOMAINNAME with domain name
4.Server runs virtDomain.tar or. sh
When the server runs the virtDomain.tar file the index file replaces the current index which already has the domain name.

I am editing my first post for better directions, please read it.
slick
HOW TO INSTALL CUSTOM ERROR PAGES ON EXISTING DOMAINS
Login to shell
CD to the users /html directory (/home/virtual/site##/fst/var/www/html)
pico .htaccess
#Add the following
ErrorDocument 401 /error_docs/401.html
ErrorDocument 403 /error_docs/403.html
ErrorDocument 404 /error_docs/404.html
ErrorDocument 500 /error_docs/500.html
[ctrl x] Click Yes, then save
mkdir error_docs
cd error_docs
pico 401.html
#Add the Following
Add 401 html here
[ctrl x] Click Yes, then save
pico 403.html
#Add the Following
Add 403 html here
[ctrl x] Click Yes, then save
pico 404.html
#Add the Following
Add 404 html here
[ctrl x] Click Yes, then save
pico 500.html
#Add the Following
Add 500 html here
[ctrl x] Click Yes, then save
chmod 0777 401.html
chmod 0777 403.html
chmod 0777 404.html
chmod 0777 500.html
foggy
QUOTE
Originally posted by slick
I am editing my first post for better directions, please read it.


Thanks for the update icon_smile.gif

I'll try this later.
Ropey
Slick,

I haven't tried your solution yet, but it looks great, thanks.

Can I just do the same, by putting everything in the /home/virtual/FILETEMPLATES so this will be added to all new accounts i create? or are there other steps to take for this?

Ropey
doneright
Thanks Slick, I have it working now.
slick
np all
QUOTE
Originally posted by Ropey
Slick,  

I haven't tried your solution yet, but it looks great, thanks.

Can I just do the same, by putting everything in the /home/virtual/FILETEMPLATES so this will be added to all new accounts i create? or are there other steps to take for this?

Ropey

No that would not work, ensim only takes certain files from it.
foggy
Thanks slick its working good now icon_smile.gif

Im interested in that script that will setup formail and ect.. during site rollout too. Do you have somthing that would do that?

Thanks.icon_biggrin.gif
slick
That can easily be done. Its just do you really want all these scripts on all domains?
Snow Wolf
it is extremely beneficial for some of us to be able to offer these scripts preinstalled. I would certainly love to know how to do all that, as it makes for dang good advertising
ohmygod
Geez... this is a really a nice add-on...

I'm looking at the howto and was wondering ... MMmm ... all this seems fairly easy to carry out ... just 1 problem...

could any one show me an example of an error html document ?

eg 404.html -> I need to know how you use the variable ENSIM_DOMAINNAME so that the actual domain name comes up ...

bear with me ... I'm not a web designer nor a coder ..... so these are reallly FOREIGN to me.

thanks ...
MindLash
QUOTE
Originally posted by slick
This will automaticly setup custom errorpages for new domains.
I used this dir as structure is setup.
NOTE: the pages wont work unless they are larger then 1kb

CUSTOM ERROR DOCS
cd /root
mkdir var
cd var
mkdir www
cd www
mkdir html
cd html
pico .htaccess
#Add the following
ErrorDocument 401 /error_docs/401.html
ErrorDocument 403 /error_docs/403.html
ErrorDocument 404 /error_docs/404.html
ErrorDocument 500 /error_docs/500.html
[ctrl x] Click Yes, then save
mkdir error_docs
cd error_docs
pico 401.html
#Add the Following
Add 401 html here
[ctrl x] Click Yes, then save
pico 403.html
#Add the Following
Add 403 html here
[ctrl x] Click Yes, then save
pico 404.html
#Add the Following
Add 404 html here
[ctrl x] Click Yes, then save
pico 500.html
#Add the Following
Add 500 html here
[ctrl x] Click Yes, then save
/etc/rc.d/init.d/httpd restart
chmod 0777 401.html
chmod 0777 403.html
chmod 0777 404.html
chmod 0777 500.html
cd /root
tar -cf virtDomain.tar var
cp virtDomain.tar /etc/appliance/customization/

UPDATED AND FIXED! No more ENSIM_DOMAINNAME problems.
Please note: Apache will ignore error pages less then 1 kb or something like that. To avoid this add a few lines of text 3-4 should do it or some html.


Thanks for the tutorial!

I know people are asking about the overwritting of the index.html files, but my question is more along the lines of a FrontPage user. I have a few of them now, and expect a few soon. In this rollout what happens to the .htaccess that is supposed to be copied over? Will it copy over the FP .htaccess file (rendering FrontPage usless) or the opposite (rendering the custom error docs useless).?

Thanks
Snow Wolf
Front page extensions always nullify ANY htaccess file on that account when activated. I've never seen htaccess files function on a website that uses front page extensions, and the control panel will warn you prior to enabling front page extensions that it will have to make the htaccess file unusable.
slick
In that case you can
pico /usr/lib/python2.1/site-packages/vh3/custom/apache.py

Place the code below inside the VirtualHost tags but outside the Directory tags

ErrorDocument 401 /error_docs/401.html
ErrorDocument 403 /error_docs/403.html
ErrorDocument 404 /error_docs/404.html
ErrorDocument 500 /error_docs/500.html


Now restart webppliance
/sbin/service webppliance restart
slick
You cant use ensim_domain however you can use a php script a use a cmnd for the domain. Checkout http://forums.rackshack.net/showthread.php...&threadid=14071
for more info
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.