【问题标题】:IIS 7.5 URL Rewrite not working? help pleaseIIS 7.5 URL 重写不起作用?请帮忙
【发布时间】:2012-02-28 14:53:17
【问题描述】:

我正在尝试重写 URL,因此它需要一个 URL,例如 my.site.com 并将其重写为“Http://localhost:8080”。我不断获得默认主页,而不是被重定向。我已将重写配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="mysite">
                <match url="(my.+)" />
                <action type="Rewrite" url="http://localhost:8080" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

我很茫然,是不是我做错了什么???

任何帮助将不胜感激。

干杯 杰夫

【问题讨论】:

    标签: url url-rewriting iis-7.5


    【解决方案1】:

    目前还不是 100% 清楚您想要实现什么以及为什么,但由于涉及到 localhost,您似乎不想重写,但可能会执行 http 重定向重写意味着你的请求 URL 被改成了另一个,比如 index_foo.htm 可以被重写为 index.aspx?what=foo。

    但是你想改变域,所以你需要重定向。试试:

    <system.webServer>
        <httpRedirect enabled="true" destination="http://localhost:8080" childOnly="false" />
    </system.webServer>
    

    这将保留您调用的任何本地页面,即。 e. my.site.com/foo.htm 将被重定向到 localhost:8080/foo.htm。

    因为这看起来像一个临时的东西用于开发目的,你可以添加

     httpResponseStatus="Temporary"
    

    到 httpRedirect(为了不丢失搜索引擎排名可能很重要)。

    【讨论】:

    • 您好 Olaf,感谢您的回复,我们正在实施一个使用 java 应用程序的公共访问网站。该应用程序将在 tomcat 上运行,因此作为一项安全要求,我们不能让 tomcat 面向公众。所以我们想让所有公共请求进入 IIS 7.5,然后将它们重定向到 tomcat。所以将所有 my.site.com 请求包括参数重定向到 http:localhost:8080 这将是 tomcat 应用程序(端口 8080 是名义上的)。
    • 然后重定向将不起作用(获取 localhost 的浏览器将尝试访问它运行的计算机)。我怀疑重写会起作用,至少不是开箱即用(Tomcat 的输出必须通过 IIS 路由,然后路由到浏览器)。我不知道任何支持该功能的工具,但您可以自己编写。浏览器输入必须在内部转发到 Tomcat,然后读取结果并发送回浏览器。
    猜你喜欢
    • 2013-07-26
    • 2023-03-08
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2013-01-06
    • 2012-05-23
    • 2015-05-11
    • 1970-01-01
    相关资源
    最近更新 更多