gpt4 book ai didi

asp.net - 带有波形符 (~) 的 IIS URL 重写问题

转载 作者:行者123 更新时间:2023-12-02 17:12:20 25 4
gpt4 key购买 nike

我有一些需要重定向的旧版 URL,这些 URL 中包含波浪号 (~)。我在使 IIS 重写规则发挥作用时遇到一些问题。

旧网址: http://www.example.com/~/media/something/whatever.pdf

需要它重定向到:/无论如何

我制定了以下规则:

Web.Config

<rewrite>
<rewriteMaps configSource="RewriteMaps.config" />
<rules configSource="RewriteRules.config" />
</rewrite>

RewriteMaps.config

<rewriteMaps>
<rewriteMap name="Legacy URLS">
<!--DOES NOT WORK-->
<add key="~/media/something/whatever.pdf" value="/whatever" />
<!--WORKS-->
<add key="/testing123" value="/whatever" />
</rewriteMap>
</rewriteMaps>

RewriteRules.config

<rules>
<rule name="Redirect rule1 for Legacy URLS" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{Legacy URLS:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>

最佳答案

我想你一定需要转义波浪号,也许是 HTML 编码: ~

( http://www.ascii.cl/htmlcodes.htm ) 或 URL 编码。

否则它的解释一定是不同的,就像应用程序主页一样。

关于asp.net - 带有波形符 (~) 的 IIS URL 重写问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35236259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com