指向 index.html“404 未找到”的 apache 符号链接

apache symlink to index.html "404 Not Found"

我在 Amazon Web Service Ubuntu 实例上安装了 apache2。如果我将 ip 放入浏览器 url 中的实例,它会成功调出默认的 apache 主页。该页面由 /var/www/html.

提供

现在我想调出存储在 /opt/Company/Product/index.html 的真实网页。我在 var/www/html 中创建了一个指向 /opt/Company/Product 的符号链接,如下所示:

ln -s /opt/Company/Product Product 

但是当我输入 ip/Product/index.html 时,出现 404 Not Found 错误。

在我的 /etc/apache2/sites-available/000-default.conf 中,我有一个这样的 VirtualHost:

<VirtualHost *:80>
   DocumentRoot /var/www/html/Product
   ServerName ip
   <Directory /var/www/html/E360_UI/>
      Options FollowSymLInks
   </Directory>    
</VirtualHost>

有什么建议吗?

您的文档根目录不应包含产品。

我怀疑您的 Apache 配置没有设置为遵循符号链接。

您需要在 Apache 配置中启用 FollowSymLinks 选项。如果主配置允许您覆盖此选项,您也可以在 .htaccess 文件中启用它。

/var/www/html 中放置一个 .htaccess 文件,其中包含:

Options +FollowSymLinks

为此,您需要将正确的 DirectoryAllowOverride 指令设置为至少 OptionsAll 也可以,如果这是当前值)