【问题标题】:Cannot serve directory /var/www/html/: No matching DirectoryIndex无法提供目录 /var/www/html/:没有匹配的 DirectoryIndex
【发布时间】:2018-06-20 19:14:36
【问题描述】:

我确定有人提出并回答了这个问题,但我没有找到解决方案。我有一个刚刚添加 SSL 的虚拟主机,但它没有按预期工作。非 SSL 版本工作正常。以下是我在 httpd.conf 中的内容:

<VirtualHost mysite.com:443>
  ServerAdmin email@myemail.com
  ServerName  mysite.com
  ServerAlias www.mysite.com
  DocumentRoot /var/www/html/www.mysite.com

  <Directory /var/www/html/www.mysite.com>
      DirectoryIndex index.html index.htm index.php
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
              Require all granted
  </Directory>

  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/my.crt
  SSLCertificateKeyFile /etc/pki/tls/private/my.key
</VirtualHost>

我得到的错误是:

[Thu Jan 11 12:29:58.984354 2018] [autoindex:error] [pid 19998] [client 
IP:38470] AH01276: Cannot serve directory /var/www/html/: No matching 
DirectoryIndex (index.html,index.php) found, and server-generated directory 
index forbidden by Options directive

显然,我将目录设置为 /var/www/html/www.mysite.com,但它试图直接从 /var/www/html 提供内容。

我确信这很简单,但我的大脑已经因为整天在这个网站上工作而变得麻木,所以我可能只是没能看到我面前的东西。

谢谢!

【问题讨论】:

  • 显然错误信息是由另一个虚拟主机产生的。
  • 不,我在下面解释了错误。

标签: apache http ssl


【解决方案1】:

修复它。很简单,就像我假设的那样。变化:

<VirtualHost mysite.com:443>

收件人:

<VirtualHost *:443>

【讨论】:

  • 嘿@james 我面临同样的问题。但是一旦我使用这个选项,我就会得到一个 502 错误。
猜你喜欢
  • 2018-10-19
  • 2016-06-18
  • 2021-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-18
  • 1970-01-01
  • 2022-01-09
相关资源
最近更新 更多