Using a question mark in the rewrite

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 25 Apr 2013, 09:17

Using a question mark in the rewrite

25 Apr 2013, 09:23

I am trying to create a rewrite rule as follows:

RewriteRule ^?ap-t-c-a-(\d+)-b-(\d+)$ /pages/pw.asp?A=$1&B=$2&Task=Click [NC,L]

So basically when someone visits my site and hits the page:

http://www.mysite.com/?ap-t-c-a-1-b-3

Its the same thing as going to http://www.mysite.com/pages/pw.asp?A=1&B=3&Task=Click

However when I try to run this rule I get an error as follows:

Unknown expression on line #78: RewriteRule ^?ap-t-c-a-(\d+)-b-(\d+)$ /pages/pw.asp?A=$1&B=$2&Task=Click [NC,L]

So I figure this has to do with the question mark.

Any help in allowing me to make this work would be very much appreciated.
Thanks

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

Re: Using a question mark in the rewrite

25 Apr 2013, 16:12

Hello,

Practically, everything after '?' is querystring. So you need the following syntax:

Code: Select all
RewriteCond %{QUERY_STRING} ^ap-t-c-a-(\d+)-b-(\d+)$ [NC]
RewriteRule ^/?$ /pages/pw.asp?A=%1&B=%2&Task=Click? [NC,L]


Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 21 guests