Apache 列出目录文件而不是 index.php

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13898386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 06:13:45  来源:igfitidea点击:

Apache lists directory files instead of index.php

phpapachedirectoryindex

提问by mavili

My Apache web server suddenly stopped serving index.php files automatically. It shows direcotry listing instead. I've tried helps but no luck.

我的 Apache Web 服务器突然停止自动提供 index.php 文件。它显示目录列表。我试过帮助但没有运气。

My htttpd.conf file includes

我的 htttpd.conf 文件包括

<IfModule module_php5>
    AddType application/x-httpd-php .php
</IfMOdule>

and

DirectoryIndex index.php index.html

What could be wrong if all above are OK?

如果以上都没有问题,可能有什么问题?

回答by mavili

I was surprised by the quick response when I first asked the question, and then the replies stopped! So I found the answer myself (by accident!). The main server root displayed index files fine, it was my user Sites folder that did not.

我第一次提问时的快速反应让我感到惊讶,然后回复停止了!所以我自己找到了答案(偶然!)。主服务器根目录显示索引文件很好,是我的用户 Sites 文件夹没有显示。

There is a .conf file for each user in apache users directory. I added

apache 用户目录中的每个用户都有一个 .conf 文件。我加了

<Directory "/Users/mavili/Sites/">
    Options Indexes MultiViews FollowSymLinks SymLinksIfOwnerMatch Includes ExecCGI
    DirectoryIndex index.php index.html index.pl index.cgi
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

into the file for my username and tata, it worked!

进入我的用户名和 tata 的文件,它起作用了!