开发者

Rewrite Rule using map AND stripping certain parameters

I'm pretty new to all this so please be basic in your explanations.

The place I work just changed store software so I have a series of URLS that need massaging as Google, people, etc continue to use the old links.

The old links look like: http://mydoman/usedateb.aspx?User_ID=38482&Category_ID=127

I know how to do a rewrite map to change http://mydomain/usedateb.aspx?Category_ID=127 to http://mydomain/hoopy-new-tour-name.aspx

And I know how to do a rewrite rule to remove the User_ID=xxx& from the Url.

My problem is in getting them both to wor开发者_开发百科k together. I need to take out the User_ID (since it's arbitrarily assigned) AND send it through the map to change to the hoopy-new-tour-name.

I have set up the rewrite rule to remove User at the top of the list and the rewrite map rule lower in the list but I end up at http://mydomain/usedateb.aspx?User_ID=38482&Category_ID=127

If it helps, my web.config has lines like

<add key="UseDateB.aspx?Category_ID=127" value="/success.htm" />

for the map and

<rule name="Remove extra parameters - UserID">
      <match url="(.*)User_ID=([0-9]+&amp;)(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="Rewrite" url="{R:1}{R:3}" appendQueryString="false" />
</rule>

to strip the unwanted parameter.

The reason I need the map is that Cat 127 may be the hoopy tour but 128 may be the frood tour. There's a list of about 500 of these that need remapping but we gotta get the extra parameter off the incoming URLs for it to work.

All help appreciated! If I'm going about it completely wrong please let me know that too.


Look at this:

         <rules>
            <clear />
            <rule name="RedirectToCategory" stopProcessing="true">
                <match url="UseDateB.aspx" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{QUERY_STRING}" pattern="Category_ID=127" />
                </conditions>
                <action type="Redirect" url="http://mydomain/hoopy-new-tour-name.aspx" />
            </rule>
            <rule name="RemoveUserID" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{QUERY_STRING}" pattern="(.*)(User_ID=[0-9]*)(.*)" />
                </conditions>
                <action type="Redirect" url="{R:0}?{C:1}{C:3}" appendQueryString="false" />
            </rule>
        </rules>

The first rule redirects based on category, and the second removes the User_ID. Try it and if you would like to do something else, state what is it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜