IIS重写不起作用(但重定向确实) [英] IIS Rewrite not working (but redirection does)

查看:1239
本文介绍了IIS重写不起作用(但重定向确实)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用重写模块2.0 进行URL重写,但我没有运气让它工作。我要做的是将端口80上的所有对Web应用程序的调用重新写入IIS中托管的其他应用程序(或者可能在网络上的不同服务器上)。使用IIS提供的GUI我创建了以下规则:

I was trying to play with URL re-writing using the Rewrite Module 2.0 but I had no luck getting it to work. What I'm trying to do is re-write all calls to web app at port 80 to other applications hosted in IIS (or maybe on different servers on the network). Using the GUI provided by IIS I created the following rule:

<rewrite>
    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="site1/(.*)" />
            <action type="Rewrite" url="http://localhost:7001/{R:1}" />
        </rule>
    </rules>
</rewrite>

安静简单,但不幸的是它不起作用。另一方面,当我将动作类型更改为重定向时,它可以正常工作。

Quiet simple, but unfortunately it does not work. On the other hand, when I change the action type to Redirect, it works fine.

可能是什么问题?

推荐答案

昨天我遇到了同样的问题,我花了很长时间才弄明白。

I ran into this same issue yesterday, and it took me a long time to figure out.

这里的关键是你的重写动作中有一个 http:// 前缀;这使得这是一个需要由应用程序请求路由处理的特殊情况。第一步是确保安装了应用程序请求路由模块。您可以在 https://www.iis.net/downloads/microsoft/application-request-找到该模块。路由。安装完成后,转到IIS Web服务器(从您的网站升级),然后打开应用程序请求路由缓存功能。从右侧的操作中,选择 Server.Proxy.Settings ,并确保选中启用代理复选框。这允许将URL重写任务重新路由到应用程序请求路由,并且您的反向代理应该适用于外部请求。

The key here is that you've got an http:// prefix in your rewrite action; that makes this a special case that needs to be handled by Application Request Routing. The first step is to make sure that the Application Request Routing module is installed. You can find the module at https://www.iis.net/downloads/microsoft/application-request-routing. Once that is installed, go to your IIS web server (a level up from your web site), and open the Application Request Routing Cache feature. From the actions on the right, choose Server.Proxy.Settings, and make sure that the "Enable Proxy" checkbox is checked. This allows the URL rewrite task to be re-routed to Application Request Routing, and your reverse proxy should work for external requests.

这个想法来自这篇优秀的博客文章来自2009: http://ruslany.net/2009/04/10-url-rewriting -tips-and-trick /

The idea came from this excellent blog post from 2009: http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

这篇关于IIS重写不起作用(但重定向确实)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆