What's wrong with this regular expression

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 5
Joined: 17 Jan 2013, 04:19

What's wrong with this regular expression

01 Nov 2013, 05:32

Hi ALL,

I don't understand that why my following regular expression can't work on RegExp Test. Can someone help me find the problem? Thanks a lot!

^subcategory\.aspx\?CatgId\=1\&subCatgId\=([0-9]+)
teststring: subcategory.aspx?CatgId=1&subCatgId=50011995

Thank you very much

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: What's wrong with this regular expression

01 Nov 2013, 07:50

The thing is that in ISAPI_Rewrite 3 the query string is matched separately:

RewriteCond &{QUERY_STRING} ^CatgId=1&subCatgId=(\d+)$ [NC]
RewriteRule ^subcategory\.aspx$ ...

User avatar
Posts: 5
Joined: 17 Jan 2013, 04:19

Re: What's wrong with this regular expression

04 Nov 2013, 00:02

Thanks for your reply, Anton.

I have try this
RewriteCond %{QUERY_STRING} ^CatgId=1&subCatgId=(\d+)$ [NC]
RewriteRule ^subcategory\.aspx$ /skincare/%1 [NC,L,R=301]
but it doesn't work. %1 cannot bring value to /skincare/%1

like this
subcategory.aspx?CatgId=1&subCatgId=123
=>
/skincare/ <= no value after skincare

thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: What's wrong with this regular expression

04 Nov 2013, 07:08

"but it doesn't work. %1 cannot bring value to /skincare/%1"
- this is strange as the rule looks fine.

Please confirm you are using ISAPI_Rewrite v3.

Enable logging by putting the following in httpd.conf:

RewriteLogLevel 9

and provide rewrite.log records for the test request subcategory.aspx?CatgId=1&subCatgId=123

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 12 guests