4

I have read the threads and I still can't work it out, my problem I know, but wondering if could point me in the right direction.

I have setup a rule:

www.mydomain.com/productlist.asp?CategoryID=2

rewritten to

www.mydomain.com/homeware/cushions

.

            <rule name="cushions">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="productlist.asp?CategoryID=2" />
            </rule>

ok, now my problem is with pagination of the results, so the original domain when the user goes onto the next page would look like:

www.mydomain.com/productlist.asp?CategoryID=2&Page=2

This is where I'm having problems - I want this to become:

www.mydomain.com/homeware/cushions?page=2

and ongoing for how many pages just can't get it to work - I understand I need to use query string but really struggling. Asking for expertise, thanks for any help

Paul Tyng
  • 7,924
  • 1
  • 33
  • 57
SuperSloth
  • 41
  • 1
  • 3

2 Answers2

2

To capture the Query String you need to use conditions for that since the match URL does not include it. So you could do that with a rule like:

<rule name="cushions" stopProcessing="true">
<match url="^homeware/cushions$" />
<conditions>
    <add input="{QUERY_STRING}" pattern="page=(\d+)" />
</conditions>
<action type="Rewrite" url="productlist.asp?CategoryID=2&amp;page={C:1}" appendQueryString="false" /> 

Carlos Aguilar Mares
  • 13,411
  • 2
  • 39
  • 36
0

Just add appendQueryString="true" in action will automatically append query string.

<rewrite>
        <rules>
            <rule name="test">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="/test/test.cfm?category=5" appendQueryString="true" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>

http://localhost:8081/homeware/cushions?page=2 You will receive page in URL variable with value 2.

Pritesh Patel
  • 1,969
  • 1
  • 18
  • 32