大网数据广告活动
服务器运维问答

Is it possible to redirect a URL from HTTP to HTTPS on the same port for IIS?

· 52CE 我爱测

I have a website located on a custom port number in the server. Currently, it is serving the users using HTTP. I was wondering if it is possible to redirect from HTTP to HTTPS while still reusing the same port number in IIS. E.g …

问题原文

原帖链接 · amsga · CC BY-SA 4.0

I have a website located on a custom port number in the server. Currently, it is serving the users using HTTP.

I was wondering if it is possible to redirect from HTTP to HTTPS while still reusing the same port number in IIS. E.g http://www.example.com:8000 becomes https://www.example.com:8000

Some of the information I have seen is that I need to use a second binding. E.g. Bind port 80 for HTTP and 443 for HTTPS and then do a redirect for port 80.

已采纳解答

原帖链接 · Sukhjinder Singh · CC BY-SA 4.0

I don't know what version of IIS you are using but if it is IIS7/7.5 then IIS URL REwrite will do just fine.

Here is a rule to copy into your root web.config

URL REWRITE

http://www.iis.net/download/urlrewrite

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
 <add input="{SERVER_PORT}" pattern="^1000$" /> 
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}:1443/{R:1}" />
</rule>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。