.htaccess troubles any advice

3 replies
Good Day Warriors

Great to meet you all however i have been trying to get a text ad rotator.php to rotate im using the include tag and its viewable just not rotating i have coded the php page to read a txt file but having difficulties. i have also found that it might be the .htaccess file and have tried varias 'AddType application/x-httpd-php5 .htm .html' would anyone know what is the correct syntax is please it`ll be much appreciated

code im using in the php file

<?php


function make_seed() {


list($usec, $sec) = explode(' ', microtime());


return ((float) $usec * 12345);


}








srand(make_seed());


$seed = rand(1000000,9999999);





srand((double)microtime()*$seed);





$file_name = 'textads.txt';


$break_txt = "--BREAK--";


$max_items = 1;


$style = "<style> P.txt { color: black; font-family: verdana; font-weight: normal; font-size: 10pt; } a:link.txt { color: blue; font-family: verdana; font-weight: bold; font-size: 12pt; } a:visited.txt { color: blue; font-family: verdana; font-weight: bold; font-size: 12pt; } </style>";


$cont = "";


$f = fopen($file_name, "r");


while (!feof($f))


{


$cont .= fread($f, 4096);


}


fclose($f);


$fitems = split($break_txt, $cont);


$items = array();


for ($j=0;$j<count($fitems);$j++)


{


;


if (strstr($fitems[$j], "href"))


$items[] = $fitems[$j];


}


$rit = array_rand($items, count($items));


print $style;


for ($i=0;$i<$max_items && $i < count($rit);$i++)


{


print str_replace("href", " class=\"txt\" href", $items[$rit[$i]]);


}


?>

Regards Jonathan
#advice #htaccess #troubles
  • Profile picture of the author boyrev
    first off, try to rename the html file .php instead of .htm(l) to ensure that it will call the include. If that's not possible, ask your hosting provider to change the configuration to accept html files as php files.
    {{ DiscussionBoard.errors[5121592].message }}
  • Profile picture of the author ernestrategos
    Code for Apache to parse php code from a html file: (.htaccess)

    RemoveHandler .html .htm
    AddType application/x-httpd-php .php .htm .html
    Signature
    {{ DiscussionBoard.errors[5121933].message }}
  • Profile picture of the author darkwizard7
    Thank to both i did get this working and the solution was changing the handler to AddType application/x-httpd-php .php5 .htm .html
    Signature
    "Victorious warriors win first and then go to war, while defeated warriors go to war first and then seek to win." - Sun Tzu
    {{ DiscussionBoard.errors[5763862].message }}

Trending Topics