问题原文
原帖链接 · OfficialCRUGG · CC BY-SA 4.0
Usually, when a directory has no index.html file in it, apache just displays a page which says "Index of /subdir" at the top and lists all the files. How is it possible to instead of this show a custom error page? Preferably something I can put in my .htaccess File
已采纳解答
原帖链接 · wurtel · CC BY-SA 4.0
By default there will be configuration line such as the following in your apache config:
DirectoryIndex index.html index.php index.cgi
This defines the order in which those files are searched for to present the content for a directory when that directory is requested without any file part. If not found, and the autoindex feature is enabled, you will get the directory contents listed.
However, it is also possible to define an absolute path for DirectoryIndex, such as:
DirectoryIndex index.html /default/index.html
Now, if there is no index.html in a directory, the contents of /default/index.html (relative to the DocumentRoot) will be used, which I believe is exactly what you're asking for.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
