【问题标题】:Apache http to https rewrite rule not working - but it was this afternoonApache http 到 https 重写规则不起作用 - 但这是今天下午
【发布时间】:2019-09-14 08:53:12
【问题描述】:

我的 apache 服务器上运行了一些站点。我对所有这些都有一个 ssl 证书。因此,我有一个虚拟主机 * 规则,应该将任何 http 流量重定向到相关的 https 站点。如果我现在尝试使用 http 访问一个站点,我会得到 apache 测试站点......但是,如果我输入 https,它就可以正常工作。

这是我所有的虚拟主机重写规则的样子:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

    RewriteCond %{SERVER_NAME} =api.mySiteName.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

有人看到任何会阻止它工作的东西吗?

【问题讨论】:

    标签: apache url-rewriting


    【解决方案1】:

    我认为您必须添加端口 443 规则。

    【讨论】:

      猜你喜欢
      • 2012-06-07
      • 2015-08-10
      • 1970-01-01
      • 2014-02-02
      • 1970-01-01
      • 1970-01-01
      • 2017-08-31
      • 2015-07-26
      • 1970-01-01
      相关资源
      最近更新 更多