grandpagenocide
10th March 2008, 00:06
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:
[...]
#application/x-httpd-php phtml pht php
#application/x-httpd-php-source phps
#application/x-httpd-php3 php3
#application/x-httpd-php3-preprocessed php3p
#application/x-httpd-php4 php4
[...]
vi /etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
# AddType application/x-httpd-php .php .phtml .php3
# AddType application/x-httpd-php-source .phps
</IfModule>
STEP 2
First lets edit apache.conf
vi /etc/apache2/apache2.conf
Towards the bottom of the apache2.conf you will find
<Directory /var/www/sharedip>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
immeidately after add
<Directory /var/www>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
Below that you will find
<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
change this to
<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Allow from root
Deny from all
</Files>
</Directory>
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.
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:
[...]
#application/x-httpd-php phtml pht php
#application/x-httpd-php-source phps
#application/x-httpd-php3 php3
#application/x-httpd-php3-preprocessed php3p
#application/x-httpd-php4 php4
[...]
vi /etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
# AddType application/x-httpd-php .php .phtml .php3
# AddType application/x-httpd-php-source .phps
</IfModule>
STEP 2
First lets edit apache.conf
vi /etc/apache2/apache2.conf
Towards the bottom of the apache2.conf you will find
<Directory /var/www/sharedip>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
immeidately after add
<Directory /var/www>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
Below that you will find
<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
change this to
<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Allow from root
Deny from all
</Files>
</Directory>
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.