I have made a PHP page which shows a list of files in one folder. Now that I don't want some one to access this folder directly, I plan to add a PHP script which redirects to index.php. Simply I don't want this file to appear in the list
Can I add exception to this extension only? or any better idea for that?
if ($handle = opendir('manual')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<a href='manual/$entry' target='_blank'>$entry</><br>";
}
}
closedir($handle);
}
If you don't want your index.php file to be displayed in this list then simply use an
if
statement.And, if you want to hide all the php files, then you can use
preg_match
: