URL重写模块-将HTTP重定向到https到特定端口

时间:2020-10-19 11:36:48

标签: ssl iis https iis-8

我正在使用URL重写将HTTP重定向到HTTPS。 所有步骤都已完成并在工作,包括web.config中的更改。 https://www.sslshopper.com/iis7-redirect-http-to-https.html

<rewrite>
      <rules>
        <rule name="RedirectToHTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
        </rule>       
      </rules>
    </rewrite>

重定向时我面临以下问题。

我想将应用程序重定向到端口90。 我有2个应用程序,一个在默认端口上,另一个在90端口上。

因此,当有人访问时- http://xxx.xxx.x.xxx:90,然后将其重定向到:- https://xxx.xxx.x.xxx

我希望它重定向到https://xxx.xxx.x.xxx:90

有人想过要怎么做吗?

1 个答案:

答案 0 :(得分:0)

将其他任何端口与https一起使用是不安全的。 https的默认端口为443。因此建议使用默认的https端口。

如果您仍要使用HTTP绑定使用其他端口,请确保您的站点绑定正确。

enter image description here

使用以下规则将HTTP重定向到https;

#! /usr/bin/env lua

for n = arg[1],  1,  -1 do
    local char = ''
    while #char < n do
        if #char %5 == 4 then char = char ..'#'
        else char = char ..'*'
        end  --  mod 5
    end  --  #char
    print( char )
end  --  arg[1]

根据要求使用https和端口90设置重定向URL。

enter image description here