繁体   English   中英

IIS URL重写多个参数

[英]IIS URL Rewrite multiple parameters

我真的对URL重写接口感到困惑。 我不明白我需要做什么。 我有一个网址为:

www.example.com/diretory/subdirectory/index.html?param1=1&param2=2&param3=2&param4=7

我想将此URL隐藏在<a> -href标记中,该标记显示“ Example Tag”。 请求网址时,应将其重写为

www.example.com/program/location/year/vacancie

我已经尝试过了:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="ProgramRewrite" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="\?([^/]+)&amp;([^/]+)&amp;([^/]+)&amp;([^/]+)" />
                <action type="Rewrite" url="www.example.com/program/location/year/vacancie" logRewrittenUrl="true" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>
</system.webServer>

在URL重写接口中, Test Pattern表示它正在工作并得到:

?param1=1&param2=2&param3=2&param4=7
param1=1
param2=2
param3=2
param4=7

我也检查了日志URL重写,但是在我的日志中未显示。

2017-03-20 16:29:24 192.168.253.146 GET /diretory/subdirectory/index.html param1=1&param2=2&param3=2&param4=7 88 - 192.168.253.146 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 304 0 0 4

ps:网址无效,仅用于说明目的。

匹配URL仅匹配URL,不考虑查询字符串。 您将需要为此添加一个条件。 您还想要重写此内容(以便服务器在内部执行新的URL)还是重定向(以便服务器将请求浏览器转到新的URL,并且地址栏中的URL更改)。 如果要重写,则不要再次添加域,如果要重定向,则也应添加http://。 假设您要使用以下规则进行重写:

 <rule name="ProgramRewrite" patternSyntax="ECMAScript" stopProcessing="true">
            <match url="(.*)" />
            <action type="Rewrite" url="/program/location/year/vacancie" logRewrittenUrl="true" />
            <conditions>
                    <add input="{QUERY_STRING}" pattern="([^/]+)&amp;([^/]+)&amp;([^/]+)&amp;([^/]+)" />
            </conditions>
        </rule>

暂无
暂无

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

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