Url with Page Number Parameter

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 6
Joined: 29 Jan 2014, 00:50

Url with Page Number Parameter

20 May 2014, 09:44

Hi there,

I'm currently using these rewrites for my category pages with a URL like such: http://mysite.com/cbdmodules/categoryte ... egoryid=72

I'd like to use a very similar rule for when my url include a page number parameter.
http://mysite.com/testa/cbdmodules/cate ... tartpage=4

I'm not sure where to add the startpage parameter to these rules.

RewriteCond %{QUERY_STRING} ^categoryID=(\d+)$ [NC]
RewriteCond ${bf_categorymap:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^CBDModules/CategoryTemplates/DetailGrid/category\.aspx$ ${bf_categorymap:%1}? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${bf_revcategorymap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) CBDModules/CategoryTemplates/DetailGrid/category.aspx?categoryid=${bf_revcategorymap:$1} [NC,L]

Any help would be appreciated.

User avatar
Posts: 6
Joined: 29 Jan 2014, 00:50

Re: Url with Page Number Parameter

20 May 2014, 18:25

A more general question to help resolve my issue. Is it possible to use mapping files with URLs that have multiple parameters? Only one of the parameters in the URL would be used with the map file.

Examples:
1) http://www.mysiste.com/category.aspx?categoryID=3 - This URL works fine with my rules in my post.

2) http://www.mysite.com/category.aspx?categoryID=3&page2 - This URL never gets rewritten with the rules I have in place. I'd like to have it rewritten exactly the same as the above URL.

Please help!
thanks
tina

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Url with Page Number Parameter

21 May 2014, 09:40

I'll answer the second one. All you need is to remove '^' and '$'. So if category parameter is present anywhere in the querystring, it gets rewritten:

Code: Select all
RewriteCond %{QUERY_STRING} categoryID=(\d+) [NC]
RewriteCond ${bf_categorymap:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^CBDModules/CategoryTemplates/DetailGrid/category\.aspx$ ${bf_categorymap:%1}? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${bf_revcategorymap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) CBDModules/CategoryTemplates/DetailGrid/category.aspx?categoryid=${bf_revcategorymap:$1} [NC,L]


However, as you can see, you completely loose other parameters in process. Is it okay?

User avatar
Posts: 6
Joined: 29 Jan 2014, 00:50

Re: Url with Page Number Parameter

21 May 2014, 13:31

Thanks Andrew, those rules work as you stated.

Unfortunately the startpage parameter is needed to determine what products are to be displayed on the category page.

I'm not sure what my choices are with using rewrite rules. SEO team doesn't want to see startpage parameter on the URL but I need it to determine the group of products that belong on the page. Of course I can make a code change to approach it differently but I was hoping a rewrite rule would do the trick.

What are my options with ISAPI rewrites to accomplish what I need?

Thanks in advance.
tina

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Url with Page Number Parameter

22 May 2014, 09:31

I'd say that you need an additional rule to one you already had. Something along the lines:

Code: Select all
RewriteCond %{QUERY_STRING} categoryID=(\d+) [NC]
RewriteCond %{QUERY_STRING} startpage=(\d+) [NC]
RewriteCond ${bf_categorymap:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^CBDModules/CategoryTemplates/DetailGrid/category\.aspx$ /%2/${bf_categorymap:%1}? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${bf_revcategorymap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (\d+)/(.+) CBDModules/CategoryTemplates/DetailGrid/category.aspx?categoryid=${bf_revcategorymap:$2}&startpage=$1 [NC,L]


You see what i'm saying?

User avatar
Posts: 6
Joined: 29 Jan 2014, 00:50

Re: Url with Page Number Parameter

09 Jun 2014, 14:39

Hi Andrew,

I see where your going with the rules but it's not quite there yet.

I've changed the rules based on your suggestion using the snippet below. The rule rewrites but no products appear so I'm guessing there is a disconnect between the categoryID parameter and the map file. Also note the startpage parameter is not required and there could be other parameters added to the URL.

The results I get are:
FROM:
http://mysite.com/cbdmodules/categoryte ... tartpage=2

Rewrites to this:
http://mysite.com/get-well-gifts

RewriteCond %{QUERY_STRING} categoryID=(\d+) [NC]
RewriteCond %{QUERY_STRING} startpage=(\d+) [NC]
RewriteCond ${bf_categorymap:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^CBDModules/CategoryTemplates/DetailGrid/category\.aspx$ ${bf_categorymap:%1}? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${bf_revcategorymap:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (\d+)/(.+) CBDModules/CategoryTemplates/DetailGrid/category.aspx?categoryid=${bf_revcategorymap:$2}&startpage=$1 [NC,L]



Thanks for your help!
tina

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 11 guests