DirectoryIndex在AWS EC2实例上不受尊重

嗨,我在这里与我的AWS EC2实例有一个非常奇怪的问题。 我已经build立了PHP5.5 MariaDB和Apache2的LAMP栈,我已经创build/启用了我的conf文件(见下)

<VirtualHost *:80> ServerName localhost DocumentRoot /var/www SetEnv APPLICATION_ENV live <Directory /var/www/> Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html index.php Order allow,deny AllowOverride All Allow from All </Directory> <IfModule mod_rewrite> RewriteEngine On </IfModule> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

甚至尝试在我的webroot中使用DirectoryIndex删除htaccess。 这些似乎没有尊重我的DirectoryIndex? 有任何想法吗? mod_dir是启用了的,还有mod_rewrite,你认为两个Apache之间就能搞清楚了吗?

您可以使用http://54.200.197.102/来检查它,安全组设置为允许在80,你可以看到我的目录结构在这里为var配音

 -rw-r--r-- 1 ubuntu ubuntu 4566 Jan 30 18:58 backup -rw-rw-r-- 1 ubuntu ubuntu 50 Jan 30 19:10 .htaccess -rw-rw-r-- 1 ubuntu ubuntu 12 Jan 30 19:09 index.html -rw-rw-r-- 1 ubuntu ubuntu 4 Jan 30 18:51 index.php 

下面是htaccess的内容

 DirectoryIndex index.php index.html 

我真的很茫然吗?

它说:“Works:index.php”。

您是否清除了浏览器caching?

Apache将通过DirectoryIndexconfigurationvariablesparsing,直到它find一个匹配,它会停止处理它在你正在浏览的目录中find的第一个匹配(在你的情况下,文档根:/ var / www)

在你的configuration中,你指定了index.html index.php这个命令,这意味着只要它在目录中看到index.html,它就会提供它,如果没有的话,它会查找index.php并在发现它时提供

如果它找不到任何一个文件,那么它将默认为您的目录索引权限的目录或最接近的匹配,在你的情况是允许的,所以它会显示目录内容

你已经覆盖了你的.htaccess中的VHOST DirectoryIndexconfiguration(这并不罕见),以便它searchindex.php然后index.html – 这是你当前看到的行为index.php是第一个匹配(即使两个文件存在)

基本上select你的首选文件,重命名另一个或其他东西或删除它和/或重新configuration你的VHOST / .htaccess文件,所以指定一个你喜欢的确切的(猜测index.php)