IIS用URL中的异常〜字符重写 [英] IIS rewrite with unusual ~ character in the URL

查看:223
本文介绍了IIS用URL中的异常〜字符重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个格式为

https://www.example.com/aaa/bbb/product/~productId=abc123

我想重定向至:

https://www.example.com/product/abc123

我对此进行了多种尝试,只是无法获得它(尽管在IIS URL重写正则表达式测试器中对此进行了测试).

I have tried a couple of variations on this and just cannot get this to pick it up (despite testing this in the IIS URL rewrite regex tester).

<rule name="Custom rule 12" stopProcessing="true">
    <match url="aaa/bbb/product/(.*)" />
    <conditions>
        <add input="{HTTP_URL}" pattern="~productId=(.*)$" />
    </conditions>
    <action type="Redirect" url="/product/{C:1}" appendQueryString="false" />
</rule>

推荐答案

根据您的描述,建议您尝试使用以下url重写规则.

According to your description, I suggest you could try to use below url rewrite rule.

            <rule name="specialcharacter" stopProcessing="true">
                <match url="aaa/bbb/product/~productId=(.*)" />
                <action type="Redirect" url="https://www.example.com/product/{R:1}" />
            </rule>

结果:

这篇关于IIS用URL中的异常〜字符重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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