强制SSL重定向 - Apache / IHS RewriteCond和RewriteRule

问题描述 投票:0回答:2

我正在尝试设置一个重写规则,它将强制所有进入端口80的请求强制使用HTTPS。

我只是围绕mod_rewrite,但这是我现在拥有的;

RewriteCond ${lowercase:%{REQUEST_URI}} /securePath$
RewriteRule ^(.*)$ https://www.mydomain.com/$1

在RewriteCond中,securePath是请求的路径(不包括我的域名)。完整的URI将是www.mydoamin.com/securePath在ReWriteRule中,$ 1应该是RewriteCond中$ {lowercase:%{REQUEST_URI}}的输出

但是,当我重新启动我的IHS服务器并尝试点击URL时,它不会强制通过HTTPS进行访问。有关这两条线路有什么问题的建议吗?

谢谢

apache mod-rewrite https
2个回答
1
投票
RewriteRule ^securePath/(.*)$ https://www.mydomain.com/$1 [NC,R=301,L]

0
投票

可能只是你的例子被打破了,但你明确地降低了传入的请求路径,并尝试将其与包含大写字母的“/ securePath”相匹配。 - 这永远不会匹配。

© www.soinside.com 2019 - 2024. All rights reserved.