【问题标题】:How can i include a page in an IIS url rewrite rule (redirect)如何在 IIS url 重写规则中包含页面(重定向)
【发布时间】:2019-11-14 09:44:22
【问题描述】:

我对 url 重写很陌生,并试图弄清楚这件事。 我有一个结构如下的网站:

http://localhost/virtualdirectory1/somepage.aspx?parameter1=x

http://localhost/virtualdirectory2/

现在我添加了一个重定向规则(入站规则): 匹配模式(正则表达式)^$ 以确保如果有人转到http://localhost,他们将被重定向到http://localhost/virtualdirectory1/somepage.aspx?parameter1=x 这也适用于正确重定向的http://localhost/?paramter1=x

这仍然允许我直接接近http://localhost/virtualdirectory2/。 但是,如果用户转到 http://localhost/somepage.aspx?paramter1=x,他们不会被重定向到 virtualdirectory1

能给我一些关于如何做到这一点的提示吗?

谢谢!

【问题讨论】:

    标签: iis url-rewriting url-rewrite-module virtual-directory


    【解决方案1】:

    这条规则是否满足您的要求?它将同时重定向http://localhosthttp://localhost/somepage.aspx?paramter1=x,但不会重定向http://localhost/

       <rule name="redirect" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{URL}" pattern="^(/somepage\.aspx)?$" />
                        </conditions>
                        <action type="Redirect" url="virtualdirectory1/somepage.aspx?parameter1=x" appendQueryString="false" redirectType="Temporary" />
                    </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-27
      • 2015-08-17
      • 2014-10-27
      • 2011-08-07
      • 1970-01-01
      • 2015-11-18
      相关资源
      最近更新 更多