Take the 2-minute tour ×

I am using Isapi Rewrite for IIS, and I want to make SEO friendly URLs for a dynamic product page.

I need to replace spaces differently in two query string parameters.

In the first param, \s should be replaced with + In the second, all \s should be replaced with -

#seo. 2 conditions. split on _ delimiter.
RewriteRule ^Store/([^_]+)_([^/]+) Store/Details.aspx?id=$1&name=$2  [QSA,NC]

#replace spaces with + in first condition (doesn't work)
#RewriteRule ^Store/([^\w\s]+)\s(.+)$ Store/Details.aspx?id=$1+$2  [QSA, NC]

#replace spaces with dash in second condition ???


Store/NP SP_name name
//$1: NP+SP
//$2: name-name
// output: Store/NP+SP_name-name

//$1: mn+98+765
//$2: name-name-name
//output: Store/mn+98+765_name-name-name
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I've done smth like that the other day, but there was a simplier task with only one type of replacement. Try using the following for basic redirect(if it works, we'll think of a more complex, multiple-parameters scenario):

RewriteRule ^Store/(.+)\s([^_]+)_(.+)\s(.+) /Store/$1+$2_$3-$4  [NC,R=301,L]

Make sure you put in on top of the existing rewrite.

share|improve this answer
Hi, That worked for NP SP_name name, but did not work for NP SP_name name name or mn%2098%20765_name%20name%20name. –  User970008 Jul 26 '12 at 2:24
Is there a way to replace all spaces in the condition? not just the first one –  User970008 Aug 2 '12 at 17:47
add comment

Your Answer


