I've created this code to random show an url on the same link. This is the file prova.php:
<?php
$file = "foto.txt";
// Convert the text fle into array and get text of each line in each array index
$file_arr = file($file);
// Total number of linesin file
$num_lines = count($file_arr);
// Getting the last array index number by subtracting 1 as the array index starts from 0
$last_arr_index = $num_lines - 1;
// Random index number
$rand_index = rand(0, $last_arr_index);
// random text from a line. The line will be a random number within the indexes of the array
$rand_text = $file_arr[$rand_index];
echo $rand_text;
$file = $rand_text;
// write out
$type = 'image/jpg';
header('Content-Type:'.$type);
header('Content-Length: ' . filesize($file));
readfile($file);
?>
This is the .htaccess:
RewriteEngine On
RewriteRule ^foto.jpg prova.php [L]
Then I go to http://mysite/folder/foto.jpg but my image don't load. Wordpress tell me that page don't exist. Instead if I go to prova.php, I see the correct link inside the file.
What is wrong?
Aucun commentaire:
Enregistrer un commentaire