0

Using ISAPI REWRITE v3

I need to replace a string in an URL. The old string is 'p=type1_' and the new is 'p=type2_'. So

http://www.somesite.com/cgi-bin/script.pl?t=something&p=type1_abcde

becomes

http://www.somesite.com/cgi-bin/script.pl?t=something&p=type2_abcde

I reckon this should work:

RewriteRule ^(.*)p=type1_(.*)$ $1p=type2_$2  [NC]

But I get a 'Pattern Not Matched' in the ISAPI_REWRITE RegexTest app as soon as the original string contains a '?' - which, in practice, it always would.

How do I do this simple search and replace?

SAL
  • 1,218
  • 1
  • 14
  • 34

1 Answers1

1

You will need to use RewriteCond %{QUERY_STRING} to search the querystring.

Try something like this:

RewriteCond %{QUERY_STRING} t=(.*)&p=type1_(.*)
RewriteRule ^cgi-bin/script.pl$ cgi-bin/script.pl?t=$1&p=type2_$2 [NC]
James Lawruk
  • 30,112
  • 19
  • 130
  • 137