我试图将HTTP流量重定向到服务器上的HTTPS。
我有this.example.net、that.example.net和etc.example.net的证书,我的DNS接受通配符。我想使用通配符永久地将HTTP重定向到HTTPS。
我试过:
<VirtualHost *:80>
ServerName example.net:80
ServerAlias *.example.net
ServerAdmin mark@example.net
RedirectMatch 301 (.*) https://$1.example.net
</VirtualHost>但这不管用。
我知道我可以这样设置单独的子域,但是可以使用通配符吗?
发布于 2019-08-08 08:03:23
正如Apache2.4httpd的RedirectMatch指令所说:
语法: RedirectMatch状态regex 此指令等价于重定向,但使用正则表达式,而不是简单的前缀匹配。 示例:
RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg"
Apache使用PCRE兼容的regexp。
但在正常情况下,应该使用:
Redirect permanent / https://www.example.com/最后但并非最不重要的部分:Redirect只匹配URL-path而不是完整的URL!
因此,您最好为您正在使用的每个子域添加一个VirtualHost配置。
https://stackoverflow.com/questions/45831109
复制相似问题