Apache2 配置在文档根目录上使用 http 而不是 https 时给出 404

Apache2 配置在文档根目录上使用 http 而不是 https 时给出 404

我目前正在尝试让我的 apache 2 服务器工作。我可以通过 https 成功连接。但 http 确实给出了 404 错误。

虚拟主机http

<VirtualHost example.com:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin [email protected]

        DocumentRoot /var/www/example.com/html
        #<Directory /var/www/example.com/html>
        #        Options Indexes FollowSymLinks MultiViews
        #        AllowOverride None
        #        Order allow,deny
        #        allow from all
        #</Directory>

        <ifmodule mod_rewrite.c="">
              RewriteEngine On
              RewriteCond %{HTTPS} off
              RewriteRule (.*) https://%{HTTP_HOST}$1 [R=301,L]
        </ifmodule>

        #SSL Redirect
        Redirect permanent / https://example.com/

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
</VirtualHost>

还有我的 https vhost

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin [email protected]

    SSLEngine on
    SSLCertificateFile      /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

    # Pfad zu den Webinhalten
    DocumentRoot /var/www/example.com/html
</VirtualHost>

谢谢参观。

答案1

我删除了 example.com:80 并将其替换为 *:80。

相关内容