How To Customize Apache2 Mod_Bwlimited Module Error Message
This guide will teach you on how to serve a customized apache2 mod_bwlimited module’s error message which is by default displayed like this.

Although the default error message is very informative enough for the webmasters/administrators to understand that the site needs a bigger bandwidth allocation, the chance on converting traffic into a revenue is zero to none.
So, here’s how to do it on a cpanel managed server.
First, Login to your server through ssh and backup the following files, just in case you need to restore them later.
/home/cpeasyapache/src/mod_bwlimited.c
/usr/local/apache/modules/mod_bwlimited.so
To make a backup of these files, execute the following commands.
cp -Rpf /home/cpeasyapache/src/mod_bwlimited.c /home/cpeasyapache/src/mod_bwlimited.c.bak
cp -Rpf /usr/local/apache/modules/mod_bwlimited.so /usr/local/apache/modules/mod_bwlimited.so.bak
Now that we have the backups, it’s time to modify the mod_bwlimited.c file.
Go to the cpeasyapache source directory.
cd /home/cpeasyapache/src
Open the mod_bwlimited.c using your favorite editor.
vi mod_bwlimited.c
Then find the line with the 509 Bandwidth Limit Exceeded
"<HTML><HEAD>\n<TITLE>509 Bandwidth Limit Exceeded</TITLE>\n"
"</HEAD><BODY>\n"
"<H1>Bandwidth Limit Exceeded</H1>\n", NULL);
Inside the head tag, insert the following html code.
"<meta http-equiv=\"refresh\" content=\"0;URL=http://www.change-this-to-your-domain.com/bwlimit.html\">\n"
Yes, you got it right, we are going to redirect all the traffic to the our custom bandwidth limit exceeded page. After adding the refresh meta tag above, the code should now be look like the one below.
"<HTML><HEAD>\n<TITLE>509 Bandwidth Limit Exceeded</TITLE>\n"
"<META http-equiv=\"refresh\" content=\"0;URL=http://www.seoroot.com/bwlimit.html\">\n"
"</HEAD><BODY>\n"
Now save the changes and exit.
press esc key then type :wq
Now, let us compile the mod_bwlimited.c using apache’s apxs tool.
/usr/local/apache/bin/apxs -iac mod_bwlimited.c
The module will be automatically copied and installed after compilation if all went well. If any case after the code compilation you got an error that it cannot copy or install the module because the file is busy, then remove the old mod_bwlimited.so module first.
rm /usr/local/apache/modules/mod_bwlimited.so
then re-compile mod_bwlimited.c.
After the installation, don’t forget to restart the apache service.
service httpd restart
If you got a warning message that it is skipping to load the module because it was already loaded, then modify your httpd.conf file and remove the duplicate loading line and restart the apache service. Everything should be working fine now.
Don’t forget to create the bwlimit.html and upload it to your server, mine looks like the one below.

Of course you can do better than that, that’s just an example.
Spread the word
del.icio.us Digg Furl Google StumbleUpon Technorati Windows Live Yahoo! Help



















Leave a Comment