AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-958541

Paulo Mendes's questions

Martin Hope
Paulo Mendes
Asked: 2022-03-27 12:34:41 +0800 CST

Apache 不会强制 https://domain 到 https://www.domain(重写不起作用)

  • 0

设置 Apache 2.4 和 Wordpress 后,我收到以下 SSL 错误消息:

$ wget "https://example.com"
Resolving example.com (example.com)... 192.168.15.5
Connecting to example.com (example.com)|192.168.15.5|:443... connected.
ERROR: no certificate subject alternative name matches
requested host name ‘ example.com’.
To connect to example.com insecurely, use `--no-check-certificate'.

为了使域名与我的 SSL 证书 ( www.example.com) 匹配,我尝试调整站点配置以将https://example.com重定向到https://www.example.com。但它不起作用:http-to-https 重定向功能如预期,但裸域到 www-domain 没有。

这是我的站点配置:

<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        Redirect permanent / https://www.example.com/
</VirtualHost>
                                                                                                  
<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
            ServerName www.example.com

            Protocols h2 http/1.1

            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            DirectoryIndex index.php

            RewriteEngine on            #### Doesn’t work at all ####
            RewriteCond %{HTTP_HOST} ^example\.com [NC]
            RewriteRule ^/(.*) https://www.example.com/$1 [L,R=301]


            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined

            # SSL with Letsencrypt                                                                                                                Include /etc/letsencrypt/options-ssl-apache.conf
            SSLEngine on
            SSLCertificateFile      /etc/letsencrypt/live/www.example.com/fullchain.pem
            SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
                                                                             
    </VirtualHost>
</IfModule>

该站点本身运行良好,并且.htaccess仅包含由 Wordpress 创建的行。

任何输入表示赞赏。

wordpress apache-2.4
  • 1 个回答
  • 28 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve