【问题标题】:IIS URL Re-write Redirect to baseIIS URL 重写重定向到基础
【发布时间】:2015-12-30 17:58:28
【问题描述】:

我希望你能帮助我,我很接近但在最后一关失败了。

如果没有从某些 IP 浏览,我正在尝试将我网站的一部分重定向到主页。但是重定向失败。

例子:

网站网址:www.mysite.com 受限路径:www.mysite.com/secure

当人们浏览时,如果他们尝试访问 /secure 路径,我希望网站自动重定向到 www.mysite.com

目前正在发生的事情是他们被转发到 www.mysite.com/www.mysite.com,我不知道为什么。

这是我的 URL 重写规则:

<rewrite>
        <rules>
            <rule name="Lockdown" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{REMOTE_ADDR}" pattern="123.123.123.123" negate="true" />
                    <add input="{REMOTE_ADDR}" pattern="111.111.111.111" negate="true" />
                    <add input="{PATH_INFO}" pattern="^/secure(.*)" />
                </conditions>
                <action type="Redirect" url="http://{Host_Header}" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>

任何想法为什么我的重定向实际上应该是?

【问题讨论】:

    标签: url-rewriting iis-7.5


    【解决方案1】:

    对于有类似问题的任何人,以下重写规则解决了我的问题。实际上我去掉了网址的 http:// 部分,但我不确定它为什么会起作用。

    <rule name="Lockdown" stopProcessing="true">
      <match url=".*" />
      <conditions>
         <add input="{REMOTE_ADDR}" pattern="123.123.123.12" negate="true" />
         <add input="{REMOTE_ADDR}" pattern="111.222.33.45" negate="true" />
         <add input="{PATH_INFO}" pattern="^/secure(.*)" />
      </conditions>
      <action type="Redirect" url="/{Host_Header}" appendQueryString="false" />
    </rule>
    

    【讨论】:

      猜你喜欢
      • 2019-02-11
      • 2011-01-16
      • 1970-01-01
      • 2016-10-10
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 1970-01-01
      相关资源
      最近更新 更多