1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Getting "Internal Server Error" with .htaccess? Here's the solution...

Discussion in 'Co-op Advertising Network' started by subhendu, Jul 26, 2005.

  1. #1
    Hi...

    After going through lots of posts, I found a solution to place co-op ads successfully into all my html pages. I'm putting down my conditions, so that, if anyone having same condition, should be able to do it errorlessly in first attempt.

    My conditions:

    1. I use Blogger's blog published to my own domain using ftp.

    2. My (cpanel/Apache) server supports PHP but runs PHP in cgi mode, so doesn't support AddType. So I cannot make HTML pages parsed as PHP on the fly. But my server supports mod_rewrite.

    3. I have already approx 11,000 pages. If you have a Blogger's Blog, you know how difficult it is to republish such a huge blog through Blogger.

    The solution:

    1. Create a file (text file) named: passthru.php and put these commands [based on Shawn's fantastic script at: http://forums.digitalpoint.com/showthread.php?t=5659]

    
    <?php
        
        if (!function_exists('file_get_contents')) {
            function file_get_contents($url) {
                $handle = fopen($url, 'r');
                $string = fread($handle, 4096000);
                fclose($handle);
                return $string;
            }
        }
        
        include ('ad_network.php');
        echo preg_replace ("/<\/body>/i", $ad_network . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
    
    ?> 
    
    PHP:
    Note: You need to change include('ad_network.php') with the filename you have (in my case, it's ad_network_328.php).


    2. Create another text file named .htaccess and put these following commands :

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
    RewriteRule ^(.*)       /passthru.php?file=$1
    </IfModule>
    Code (markup):
    3. Create a blank text file and name it : (in my case) ad_network_ads_328.txt

    4. Upload these three files to your public_html or www folder.

    5. Change the permission of ad_network_ads_328.txt from 644 to 666.

    6. Now, view your site. If you can see co-op ads at the bottom of your pages, you are done. If you get 'Internal Server Error', try to change these lines in your .htaccess file :

    From:
    RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]

    To:
    RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]

    Note: There is only a difference of "\" before .htm and .html.


    Well, this has worked for me to display co-op ads on my pages.

    However, I am not yet able to validate my site and I have no clue why it is not validating. I'll post a seperate post for that.

    Hope this helps,

    Regards

    Subhendu Sen
    http://www.allindianews.in/
     
    subhendu, Jul 26, 2005 IP