ฉันได้ตั้งค่าโฮสต์เสมือนของฉันบน Apache 2.4.7 ด้วยการกำหนดค่าพื้นฐานมาก:
<VirtualHost *:80>
ServerName foo.example.com
DocumentRoot /var/www/html
DirectoryIndex index.php
FallbackResource /index.php
</VirtualHost>
ภายใต้รูทเอกสารฉันมีโครงสร้างต่อไปนี้:
/index.php
/help/readme.txt
ฉันได้รับผลลัพธ์ต่อไปนี้เมื่อฉันขอ:
/bla -> 200 OK
/help/ -> 404 Not Found
/help/a -> 200 OK
ดูเหมือนว่าการมีอยู่จริงของ/help/ไดเรกทอรีทำให้ Apache กลับมา404เพราะไม่มีindex.phpในนั้น แต่ฉันคาดว่าการร้องขอทั้งหมดจะเรียก/index.phpและทำให้การ200 OKตอบสนอง
ฉันจำไม่ได้ว่านี่เป็นปัญหาเมื่อใช้mod_rewriteแต่ฉันชอบใช้FallbackResourceถ้าเป็นไปได้ มีวิธีแก้ไขปัญหานี้หรือไม่?
ปรับปรุง
มันทำงานได้ถ้าผมเอาDirectoryIndexคำสั่ง แต่ทุกข์ว่าจากประเด็นที่ห้าวินาที
อัปเดต 3
ฉันใช้สภาพแวดล้อมการทดสอบต่อไปนี้ โครงสร้างไดเรกทอรีเป็นดังนี้:
./htdocs
index.html
test/
bla.txt
./conf
httpd.conf
./logs
เนื้อหาของhttpd.confคือ:
ServerName apache-bug.local
Listen 8085
DirectoryIndex disabled
DirectorySlash Off
<VirtualHost *:8085>
DocumentRoot /home/user/apache-bug/htdocs
FallbackResource /index.html
</VirtualHost>
ฉันconfig.niceมี:
"./configure" \
"--enable-debugger-mode" \
"--with-apr=/usr/local/apr/bin/apr-1-config" \
"--enable-dir=static" \
"--with-mpm=prefork" \
"--enable-unixd=static" \
"--enable-authn-core=static" \
"--enable-authz-core=static" \
"$@"
ในการรันเซิร์ฟเวอร์:
httpd -X -d /home/user/work/apache-bug/
/bla?