【问题标题】:URL Rewriting in IIS with Express使用 Express 在 IIS 中重写 URL
【发布时间】:2020-11-10 09:58:17
【问题描述】:

我想将所有图像重写到不同的文件夹。我正在使用 IIS,并在 web.config 中配置了一条规则,将所有请求重定向到 node.js 文件,如下所示:

<rewrite>
    <rules>
        <rule name="img">
            <match url="\/(.*).img" />
            <action type="Rewrite" url="/handlers/img.js" />
        </rule>
    </rules>
</rewrite>

现在所有请求都被发送到 img.js 文件,根据条件,我想重定向到另一个图像文件。但是 IIS 现在将该文件发送到 img.js 并最终形成一个循环。有没有办法摆脱这个循环?

【问题讨论】:

标签: express redirect iis


【解决方案1】:

您可以尝试以下方法来解决问题:

设置条件不匹配模式:

 <conditions>
                    <add input="{REQUEST_URI}" pattern="\/(.*).img.js" negate="true" />
                </conditions>

或设置&lt;rule name="img" stopProcessing="true"&gt;

<rule name="img" stopProcessing="true">
                <match url="\/(.*).img" />
                <conditions>
                    <add input="{REQUEST_URI}" pattern="\/(.*).img.js" negate="true" />
                </conditions>
                <serverVariables />
                <action type="Rewrite" url="/handlers/img.js" logRewrittenUrl="true" />
            </rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    • 1970-01-01
    • 2017-12-15
    • 1970-01-01
    • 2010-11-04
    • 1970-01-01
    • 2015-10-09
    相关资源
    最近更新 更多