使用IIS重写URL重写帮助

时间:2013-11-09 04:09:53

标签: iis url-rewriting

请帮助我使用IIS重定向我的URL重写以下内容:

https://domain.com:8080/Context/services/.*

https://domain.com:8443/Context/services/.*

我们只有8080端口打开,这就是为什么需要重定向SSL。

但与此同时,我不希望任何其他网址被重定向,例如 https://domain.com:8080/Context/xyz(或除服务外的任何事项)/.*

我尝试了以下操作,但它无法正常工作:

<rule name="HTTPS Request on 8080 Redirect to HTTPS Request on 8443 for Root" 
      patternSyntax="ECMAScript" stopProcessing="true">
    <match url="https(.*)Context/services/.*" />
    <conditions>
        <add input="{SERVER_PORT}" pattern="8080" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}:8443/{R:0}" />
</rule>

1 个答案:

答案 0 :(得分:0)

尝试一下:

<rule name="HTTPS Request on 8080 Redirect to HTTPS Request on 8443 for Root" 
     patternSyntax="ECMAScript" stopProcessing="true">
    <match url="^(Context/services/.*)" ignoreCase="true" />
    <conditions>
        <add input="{SERVER_PORT}" pattern="8080" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}:8443/{R:0}" />
</rule>

如果您查看Accessing URL Parts section here,您会注意到匹配网址包含放置目录根目录之后的所有内容。对于根目录中的内容,就像您的情况一样,它将是没有前导斜杠的主机名和端口/.