url重写规则以动态解析url

问题描述 投票:0回答:1

我正在使用重写地图方法来实现我的seo友好网址。

        <rewriteMaps>
            <rewriteMap name="Destinations">
                <add key="/point-a-to-point-b" value="/destination-final.asp?from=point%20a&amp;to=point%20b" />
            </rewriteMap>   
        </rewriteMaps>
            <rules>
            <rule name="Rewrite rule1 for Destinations">
                <match url=".*" />
                <conditions>
                    <add input="{Destinations:{REQUEST_URI}}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="{C:1}" appendQueryString="false" />
            </rule> 
        </rules>

我的问题是我有太多的目的地,并且必须为500个错误中的每个结果写一张地图。我相信你可以在单个web.config文件上拥有的地图数量有限。

是否可以使用通配符规则实现此目的?

会解析url并使用“to”之前的位作为起点,将“to”之后的位作为终点并将其作为查询字符串发送到文件中?

例如

/ geo-york-to-tox

会发送以下查询字符串:

从纽约=&到=得克萨斯

url-rewriting iis-8
1个回答
1
投票

你能否分享500错误的详细错误消息。如果你想要达到你的要求/ newyork-to-texas from = newyork&to = texas你可以使用下面的url重写规则:

<rule name="send value to query string" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{REQUEST_URI}" pattern="(.*)/(.*)\-to\-(.*)" />
                </conditions>
                <action type="Redirect" url="http://localhost:746/default.aspx?from={C:2}&amp;to={C:3}" appendQueryString="false" />
            </rule>

enter image description here

此致,Jalpa。

© www.soinside.com 2019 - 2024. All rights reserved.