且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 index.html 设为默认值,但如果输入,则允许访问 index.php

更新时间:2023-12-03 08:05:46

默认情况下,DirectoryIndex 设置为:

By default, the DirectoryIndex is set to:

DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml

Apache 将按顺序查找上述每个文件,并在访问者仅请求目录时提供它找到的第一个文件.如果 Web 服务器在当前目录中找不到与 DirectoryIndex 指令中的名称匹配的文件,则会向浏览器显示目录列表,显示当前目录中的所有文件.

Apache will look for each of the above files, in order, and serve the first one it finds when a visitor requests just a directory. If the webserver finds no files in the current directory that match names in the DirectoryIndex directive, then a directory listing will be displayed to the browser, showing all files in the current directory.

顺序应该是DirectoryIndex index.html index.php//默认是index.html

The order should be DirectoryIndex index.html index.php // default is index.html

参考: 这里.