简体   繁体   English

IIS URL重写问题Tilde(〜)

[英]IIS URL Rewrite issue with Tilde (~)

I have some legacy URLs that I need to redirect that have a tilde (~) as part of the URL. 我有一些遗留的URL,我需要重定向,有一个波浪号(〜)作为URL的一部分。 I'm having some issues getting the IIS Rewrite rules to work. 我有一些问题让IIS重写规则工作。

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

Need it to redirect to: /whatever 需要它重定向到:/无论如何

I have the following rules in place: 我有以下规则:

Web.Config Web.Config中

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

RewriteMaps.config 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 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>

I'm thinking you must need to escape the tilde, perhaps HTML Encode: &#126; 我想你必须要逃脱代字号,也许是HTML Encode: &#126;

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

Otherwise it must be interpreting ~ differently, a la application home. 否则它必须以不同的方式解释,一个应用程序回家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM