Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

Adding an additional parameter to a URL rewrite rule

$
0
0

I have the following re-write rule:

 <rule name="machine-tools refine url with location" stopProcessing="true">
<match url="^(machine|construction|lifting|miscellaneous|woodworking)/([^/]+)/([^/]+)/(.*)$" />
<conditions trackAllCaptures="true">
<add input="{R:4}" pattern="^(?:(new|used)(?:$|/))?([^/]*)?/?([^/]*)?/?((page)\d*)?/?" />
<add input="{States:{C:2}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="/pages/search.aspx?ind={R:1}&amp;cat={R:2}&amp;subcat={R:3}&amp;loc={C:4}&amp;manf={C:3}&amp;cond={C:1}&amp;pg={C:5}" />
</rule>

This rule sorta works. The problem is with the last bit in the input pattern: ((page\d*)

What i want is for there to be an optional parameter at the end of the url that will look like page#. I just need the # part, although if it returns page# that's fine as well as i can strip out the 'page' part.

This rule has some funky behavior.

If the url looks like /machine/cat/subcat/used/acme/page12

then pg=page

with a url of /machine/cat/subcat/used/page12 pg is blank, but manf=page12

and with a url of /machine/cat/subcat/page12 pg=page

Just for clarity, machine/cat/subcat will always be present - all other values are optional. There's also a 2nd rule which adds another parameter, location. But I think once i get this rule working i can modify the other one on my own.

This is being done in IIS express and will be deployed to an IIS 7/win2k8 r2 server and url rewrite v2

Thanks


 


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>