【问题标题】:IIS url redirection too many redirectIIS url 重定向太多重定向
【发布时间】:2021-03-25 18:51:39
【问题描述】:

我需要将名为“www.mydomain.com”的网址重定向到“www.mydomain.com/index.php?id=1”。我在 IIS 上配置了 http 重定向,但出现了太多重定向错误。我也尝试通过 url rewrite 模块来做,但我得到了同样的错误。如果我选中附加查询字符串框,则 url 显示“www.mydomain.com/index.php?id=1&id=1&id=1&id=1...”。 &id=1 显示了很多次。我的网络配置重写规则如下:

<rules>
                <rule name="redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Redirect" url="/index.php?id=1" appendQueryString="true" />
                    <conditions>
                    </conditions>
                </rule>
</rules>

谁能帮帮我。我整天都在尝试这个。谢谢。

【问题讨论】:

  • 这主要是你的重写规则有问题,导致循环重定向。你需要修改你的重写规则。

标签: redirect iis-10 url-rewrite-module


【解决方案1】:

您正在重定向一个空路径。因此,从技术上讲,您将匹配每个重定向并继续将查询字符串映射到末尾。

  1. 在提供的模式框中,为空路径添加 REGEX 表达式。这是以下组合之一:

    • ^$
    • ^/?$
    • ^\/?$(我认为这种转义没有必要,但如果可行的话值得一试。)
  2. 您还可以更改 web.config 以匹配空路径,然后重定向。

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Redirect to /index.php?id=1" stopProcessing="true">
                        <match url="^$" />
                        <action type="Redirect" url="/index.php?id=1" redirectType="Found" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
  3. 另一个可行的选择....您没有列出传输层 (HTTP | HTTPS),但如果您从 HTTP -> HTTPS 重定向,您可以尝试以下解决方案:IIS URL Rewrite module repeats query string

【讨论】:

  • 我想知道这些是什么意思? ^$ ^/?$ ^\/?$ (.*) * 如果我想重定向到 url 但使用 https,我应该创建另一个规则吗?
猜你喜欢
  • 2021-06-23
  • 1970-01-01
  • 2019-02-11
  • 2018-04-15
  • 2017-04-12
  • 1970-01-01
  • 2015-01-14
  • 2011-06-24
  • 1970-01-01
相关资源
最近更新 更多