简体   繁体   English

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

[英]Force SSL redirect - Apache/IHS RewriteCond and RewriteRule

I'm trying to set up a rewrite rule which will force all requests coming in on port 80 to use HTTPS by force. 我正在尝试建立一个重写规则,该规则将强制所有进入端口80的请求强制使用HTTPS。

I'm only getting my head around mod_rewrite but this is what i currently have; 我只是想了解mod_rewrite,但这就是我目前拥有的;

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

In the RewriteCond securePath is the requested path (not including my domain).The full URI would be www.mydoamin.com/securePath In the ReWriteRule $1 is supposed to be the output from ${lowercase:%{REQUEST_URI}} in the RewriteCond 在RewriteCond中,securePath是请求的路径(不包括我的域)。完整的URI为www.mydoamin.com/securePath在ReWriteRule中,$ 1应该是RewriteCond中$ {lowercase:%{REQUEST_URI}}的输出。

However when i restart my IHS server and attempt to hit the URL it isint forcing access through HTTPS. 但是,当我重新启动IHS服务器并尝试访问URL时,它不是强制通过HTTPS进行访问。 Any suggestions on what is wrong with these two lines? 关于这两行有什么问题的任何建议?

Thanks 谢谢

RewriteRule ^securePath/(.*)$ https://www.mydomain.com/$1 [NC,R=301,L]

Probably it's just you example being broken, but you are explicitly lowercasing the incoming request path and try to match that to "/securePath" which includes a capital letter. 可能只是您的示例被破坏了,但是您明确地简化了传入的请求路径,并尝试将其匹配到包含大写字母的“ / securePath”。 -That is never going to match. -那是永远不会匹配的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM