ความลับทั้งหมดก้ออยู่ที่ .htaccess นี่เอง

ผมเ็ห็นหน้า Ubuntu CD Image ทีไรต้องนึกทุกทีว่าเขาทำยังไงให้หน้าที่ไม่มี index ซึ่งหน้าแบบนี้มันเป็นหน้าที่ต้องแสดงรายชื่อไฟล์ ให้ดาวน์โหลด แต่ทำไมถึงมีหน้า html สวยๆ อยู่ข้างบนได้ หรือเขาเขียน index script ครอบไปอีกทีหรือเปล่า? บังเอิญเข้าไปที่ mirror.in.th พบว่าหน้าตาของ mirror ไม่เหมือนกับของ Ubuntu CD Image เท่าที่ดูโครงสร้างเลยถึงบางอ้อเลย ก้อ lightHTTP มันไม่อ่าน .htaccess นี่นา เอ้าถ้าอย่างนั้นความลับทั้งหมดก้ออยู่ที่ .htaccess นี่เอง มาดูข้างในกันเลยครับ

AddDescription "Install/live DVD for PC (Intel x86) computers (<a href=\"https://help.ubuntu.com/community/BitTorrent\">BitTorrent</a> download)" ubuntu-8.04.1-dvd-i386.iso.torrent
AddDescription "Install/live DVD for PC (Intel x86) computers (standard download)" ubuntu-8.04.1-dvd-i386.iso
AddDescription "Install/live DVD for PC (Intel x86) computers (file listing)" ubuntu-8.04.1-dvd-i386.list
AddDescription "Install/live DVD for PC (Intel x86) computers (contents of live filesystem)" ubuntu-8.04.1-dvd-i386.manifest
AddDescription "Install/live DVD for 64-bit PC (AMD64) computers (<a href=\"https://help.ubuntu.com/community/BitTorrent\">BitTorrent</a> download)" ubuntu-8.04.1-dvd-amd64.iso.torrent
AddDescription "Install/live DVD for 64-bit PC (AMD64) computers (standard download)" ubuntu-8.04.1-dvd-amd64.iso
AddDescription "Install/live DVD for 64-bit PC (AMD64) computers (file listing)" ubuntu-8.04.1-dvd-amd64.list
AddDescription "Install/live DVD for 64-bit PC (AMD64) computers (contents of live filesystem)" ubuntu-8.04.1-dvd-amd64.manifest

HeaderName HEADER.html
ReadmeName FOOTER.html
IndexIgnore .htaccess HEADER.html FOOTER.html
IndexOptions NameWidth=* DescriptionWidth=* SuppressHTMLPreamble FancyIndexing IconHeight=22 IconWidth=22

AddIcon /cdicons/folder.png ^^DIRECTORY^^
AddIcon /cdicons/iso.png .iso
AddIcon /cdicons/jigdo.png .jigdo .template
AddIcon /cdicons/list.png .list .manifest .html MD5SUMS MD5SUMS.gpg
AddIcon /cdicons/torrent.png .torrent

RedirectPermanent /releases/hardy/release/ubuntu-8.04-dvd-amd64.iso http://old-releases.ubuntu.com/releases/hardy/ubuntu-8.04-dvd-amd64.iso
RedirectPermanent /releases/hardy/release/ubuntu-8.04-dvd-i386.iso http://old-releases.ubuntu.com/releases/hardy/ubuntu-8.04-dvd-i386.iso

ดูตรงตัวหนาๆ 4 บรรทัดครับ เขากำหนด HeaderName กับ ReadmeName ขึ้นมานี่เอง ส่วนบังคับไม่ให้แสดงไฟล์ใดๆ ก้อบรรทัดที่ 2 ครับ ตรง IndexIgnore ในส่วน IndexOptions เป็นการกำหนดความกว้างของชื่อไฟล์ และคำอธิบายชื่อไฟล์

ลองเอาไปประยุกต์ใช้กันดูนะครับ