0
我在我的網絡上爲我的電影運行Apache服務器。我最近發現.HTACCESS的威力,並決定嘗試使用它來使我的所有目錄看起來不錯,而不是默認索引。問題是我使用一個基本的PHP腳本,它只獲取當前目錄,而不是像我想要的那樣從所有電影目錄中獲取。我這樣做的原因是,我不必將索引文件複製/粘貼到我的每個540文件夾中。我不確定是否有什麼我做錯了或我可以使用一些不同的PHP。任何幫助讚賞。Apache HTACCESS目錄/錯誤的php代碼?
這是我的.htaccess
# DISABLE DIRECTORY VIEWS
Options +Indexes
# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
</Files>
# DIRECTORY CUSTOMIZATION
<IfModule mod_autoindex.c>
</IfModule>
# SET INDEX OPTIONS
IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=70 DescriptionWidth=* VersionSort SuppressHTMLPreamble IconWidth=40 SuppressDescription SuppressLastModified SuppressSize HTMLTable
# SPECIFY HEADER FILE
HeaderName /header.php
# SPECIFY FOOTER FILE
ReadmeName /footer.html
# IGNORE THESE FILES
IndexIgnore header.html index.php *.nfo *.txt *.srt footer.html favicon.ico .htaccess .ftpquota .DS_Store icons *.log *,v *,t .??* *~ *# Thumbs.db
DirectoryIndex index.html index.php
這是我的PHP:
<?php
// open this directory
$myDirectory = opendir(".");
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=10 cellspacing=0 class='main'>");
Print ("<td><b>$indexCount movies</b></td>");
//print("<TR><TH>Filename</TH></TR>\n");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){// don't list hidden files
print("<TR><TD width='50%'><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
print("</TR>\n");
}
}
print("</TABLE>\n");
?>
很抱歉,如果我是小白,但我擺脫了PHP,並加入 在體內,該腳本未加載 –
我想通了,但我得到一個錯誤,它無法找到類。致命錯誤:在'我的PHP文件*'中找不到類'DirectoryReader'。我試圖把這個類放在php文件中,並將它放在它自己的.js文件中,並使用腳本src,但仍然是相同的錯誤。 –
我得到了腳本工作,我現在該做什麼!它顯示每個目錄中的每個文件。不知道該從哪裏出發。 –