如何将IIS服务器中的特定端口重定向到其他端口

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

我的URL重写规则仅适用于IIS中的端口80。

重写适用于:http://localhost:80 - > http://localhost:8100

重写适用于:http://localhost:80/redirect - > http://localhost:8100

重写不起作用:qazxsw poi - > qazxsw poi

重写不起作用:qazxsw poi - > qazxsw poi

我的web.config如下:

http://localhost:8080

web.config仅适用于默认的http端口80/443,但不适用于特定端口。

必须在web.config中进行哪些更改才能使用所有端口?

redirect iis web url-rewriting port
1个回答
0
投票

主要问题是变量http://localhost:8100已经包含http://localhost:8080/redirect信息。

要解决此问题,您需要调整两件事:

  1. 扩展匹配模式
  2. 设置重定向的正确地址

我调整了你的http://localhost:8100,看看它应该如何与你的例子一起工作:

<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
<system.webServer>
    <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" />
    <rewrite>
        <rules>
            <rule name="Redirect to port 8100" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{SERVER_PORT}" pattern="^8100$" negate="true" />
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}:8100/{R:0}" />
            </rule>
        </rules>
    </rewrite>
 </system.webServer>
</configuration>
© www.soinside.com 2019 - 2024. All rights reserved.