Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
458 views
in Technique[技术] by (71.8m points)

url rewriting - IIS Redirect http on port 8880 to https on port 8443

I am rather struggling here. I've seen lots of answers for 80 to 443, but I'm really stuck with 8880 to 8443 for our control panel.

An example of a URL that needs redirecting: http://udweb01.servers.unreal-designs.co.uk:8880/admin/home?context=home

It should result to this: https://udweb01.servers.unreal-designs.co.uk:8443/admin/home?context=home

Note the http -> https and 8880 -> 8443.

The current rule we have is this:

<rule name="Force SSL (8443)" enabled="true" stopProcessing="true">
  <match url="^(http://)?(.*):8880(/.*)?$" />
  <action type="Redirect" url="https://{R:2}:8443{R:3}" appendQueryString="true" redirectType="Found" />
</rule>

But that doesn't seem to do anything. Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your rule should be like that:

<rule name="Redirect with port" stopProcessing="true">
     <match url=".*" />
     <conditions>
          <add input="{HTTP_HOST}" pattern="^(.*):8880$" />
     </conditions>
     <action type="Redirect" url="https://{C:1}:8443/{R:0}" />
</rule>

In this rule you have condition <add input="{HTTP_HOST}" pattern="^(.*):8880$" /> which will accet only http host with port 8880


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...