Apache 域未指向 DocumentRoot (DigitialOcean Moodle)

Apache Domain not pointing to DocumentRoot (DigitialOcean Moodle)

我是 运行 ubuntu 18.4,安装了 digitalocean lamp 包括 quickstart ssl。我在服务器上的子目录 /var/www/html/moodle.

中成功安装了 moodle 应用程序

我的问题如下: 如何将我的子文件夹指向主域,例如https://example.org/moodle to https://example.org

我的建议很简单,将 apache site-enabled/moodle.conf DocumentRoot 更改为 /var/www/html/moodle.

这没有效果。访问 https://example.org 只会显示来自 digitalocean 的 /var/www/html/index.html 文件。

奇怪的是,即使我将 documentroot 指向一个不存在的文件,例如 /var/www/html/moodle_2,它也没有任何效果。

我猜 moodle.conf 没有被使用。 (-> 为什么??如何激活?运行 sudo a2ensite moodle.conf 导致 Site moodle already enabled)

现在,我搬家并开始更改/etc/apache2/sites-available/000-default-le-ssl.conf中的设置。这产生了直接的影响。

如果我将 DocumentRoot 设置为 /var/www/html/moodle,我的服务器不会显示任何内容。意思是,当您访问该域时,他会事先显示默认的 digitalocean 站点。当您导航到 example.org/moodle 时,正在显示 moodle 应用程序。现在我刚收到消息。 /moodle 未找到。

我只想在访问 example.org 时使用 moodle 作为默认站点。

任何想法将不胜感激。

我按照本教程安装了 moodle:https://www.digitalocean.com/community/tutorials/how-to-install-moodle-on-ubuntu-16-04

谢谢

添加具有以下内容的.htaccess文件完美解决了这个问题,因为它在子文件夹中。

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/moodle/

# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /moodle/ [L]