Question

I'm struggling to get some code working for an old ASP store site I manage - I have added the following which works perfectly well

RewriteBase /
RewriteRule ^cat/[^?/]*_(\d+)\.htm /store/prodList.asp?idcategory=$1 [QSA]

Problem is if the category page has more than one page! As it adds another couple of parameters to the querystring like so

/store/prodList.asp?idcategory=102&curPage=2&sortField=sortorder

I'm looking for an example of taking three more querystring parameters and appending it to the rewritten URL... Can anyone help please?

So for example, currently the following URL works fine

cat/productname_5.htm ... equates to ... /store/prodList.asp?idcategory=5

I need to do something like the following when I have more than one page? but don't know the ISAPI syntax?

cat/productname_5_2_sortorder.htm ... would equate to ... /store/prodList.asp?idcategory=5&curPage=2&sortField=sortorder

I hope that makes more sense?

Was it helpful?

Solution

I think this is what you are asking, set the [L] argument to make it stop matching on first match. ?

But [L] requires you to order them by most restrictive first, 4 args, then 3, 2 etc...

  ReWriteRule ^/store/([0-9]+)/([0-9]+)/{0,1}$ /store/prodList.asp\?idcategory=$1&curPage=$2 [L]

  ReWriteRule ^/store/([0-9]+)/([0-9]+)/([A-Za-z]+)/{0,1}$ /store/prodList.asp\?idcategory=$1&curPage=$2&sortField=$3 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top