【问题标题】:Simply URL Rewrite not working简单的 URL 重写不起作用
【发布时间】:2016-11-17 03:50:26
【问题描述】:

我正在尝试设置一个 IIS URL Rewrite 函数来简单地将任何 URL 请求发送到 google(作为测试):

            <rule name="Intercept" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="google-homepage-url-here" appendQueryString="false" logRewrittenUrl="true" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="example.com$" />
                </conditions>
            </rule>

我使用 Rewrite 而不是 Redirect,因为我需要对用户隐藏 URL。上面的配置适用于 Redirect,但不适用于 Rewrite,这是为什么呢?

当我点击http://example.com/blablabla 时,我得到一个 404.4

我的目标是让用户被引导到谷歌主页。

我已经安装了 ARR,有什么想法吗?

【问题讨论】:

  • 有什么想法吗?重写似乎是一个非常灰色的区域。

标签: iis url-rewriting iis-7


【解决方案1】:

如果你希望用户被引导到谷歌主页,你应该使用重定向,而不是重写。这不是“向用户隐藏 url”,而是在服务器端处理。

如果没有任何日志,我只能建议您的 IIS 正在尝试重写到 google,向它询问一些不存在的页面并且显然返回 404。例如,如果您的网站使用 http 而 google 服务器使用 https,则可能会发生这种情况。

我认为您还应该检查重定向和重写之间的区别,this 文章是一个好的开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 2017-10-06
    • 2016-02-25
    • 2018-02-09
    • 2017-01-13
    相关资源
    最近更新 更多