Forced ads for ISPConfig with .htaccess . I wrote this “how to” for those who want to place forced ads on their ISPConfig server. Probably you can setup forced ads in different ways but I found the way descibed here. I am using Debian Etch and ISPConfig 2.2.19 in this example. What needs to be done: - edit apache config - create .htaccess files - create header and footer with ads - disable the ads on accounts that upgrade I had to enable php server wide for this to work, and since i give all my clients php, it is not a big deal, but if anyone can update this with a meathod to only allow php in the /var/www and /var/www/ads that would be appreciated Let’s show where our ISPConfig server is capable of, here we go: STEP 1 Enable php system wide vi /etc/mime.types uncomment out the following: vi /etc/apache2/mods-enabled/php5.conf STEP 2 First lets edit apache.conf vi /etc/apache2/apache2.conf Towards the bottom of the apache2.conf you will find immeidately after add Below that you will find change this to save and /etc/init.d/apache2 restart STEP 3 Now lets create a directory mkdir /var/www/ads STEP 4 we are going to create two php files now lets make footer.php with your footer ad and lets make blank.php that is actually blank STEP 5 Creating .htaccess file use any text editor you like most of them will give you another extention, but rename the file to .htaccess and have it contain the following: php_value output_buffering 4098 AddType application/x-httpd-php htm AddType application/x-httpd-php html php_value auto_append_file '/var/www/ads/footer.php' And thats it, now every site on the server will have your forced footer, the same goes if you want a header. TO DISABLE ADS ON AN INDIVIDUAL SITE Create another .htaccess file with the following php_value output_buffering 4098 AddType application/x-httpd-php htm AddType application/x-httpd-php html php_value auto_append_file '/var/www/ads/blank.php' and place it in the /web directory of that site And thats it guys, you now have forced ads. I am going to try to write a module that will allow this to be controled from ispconfig cp.
Trying to replicate it ok i am trying to replicate it on another server, and for some reason I am getting this error, it is working fine on one server, how do I remove the basedir restriction?
It works fine the clients site i was viewing had an htaccess in it for chinese encoding and muffed it up
I worked on this code some so here i have some good stuff for you Ok first code i will give you is to not auto add it to every account but FORCE it on every account no matter what before they could just edit out the ad's part of the .htaccess file so. Go to: /root/ispconfig/isp/conf/ Edit File: vhost.conf.master Go to the bottom you will see this Right Below that add That is the code for your ad replace header.php with your ad file name Also if you want your ad on the top or the bottom of the page Top of page: php_value auto_prepend_file '/var/www/ads/header.php' Bottom of page: php_value auto_append_file '/var/www/ads/header.php' This code can not be removed from any site so i made a mod for the ad file you will not need blank.php anymore so you can delete it. So in your ad file right now you have your ad code thats it, Change your file so its like this. It works great!
Hmmm...What if I only want this on certain accounts? Say like, not server wide, but on free hosting that I offer. If those accounts ONLY get ads, and not the paid hosts? If there is a way, other than adding each paid account to the ad file.
Ballistic, if you use the htaccess meathod i layed out, you can control it through the htaccess files, who has ads and who doesnt.
but if i do that then i risk the chance that the user deletes the htaccess file or ad line correct? ISPConfig should include a module for this to select which plans have forced ads. OR can I add code to something to select which plans do have ads?
If I have this .htaccess file setup on the server, can I have the signup script (the custom framework example) copy this file to the new account directory and then chmod it to root? If so, where would I add it in the script?
yes you can i just havent had time to go back and work that into it yet so just ask around you may find a thread or two about custom templates on signup.