处理 - 参数值中的字符

My url :

http://www.abc.com/search_result.php?parrent_prop_type=value1&prop_type_name=-value2&location=value-3&prop_type_auto_id=value4

want to change

http://www.abc.com/value1-value2-value-3-value4

My rule :

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search_result\.php\?parrent_prop_type=([-0-9a-zA-Z]+)\&prop_type_name=([-0-9a-zA-Z]+)\&location=([-0-9a-zA-Z]+)\&prop_type_auto_id=([-0-9a-zA-Z]+) [NC]
RewriteRule ^ http://abc.com/%1-%2-%3-%4? [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([-0-9a-zA-Z]+)-([-0-9a-zA-Z]+)-([-0-9a-zA-Z]+)-([-0-9a-zA-Z]+)/?$ search_result.php?parrent_prop_type=$1&prop_type_name=$2&location=$3&prop_type_auto_id=$4 [NC]

Rewrite working properly, But problem on search_result.php. Actually search_result.php not working properly. I can't get the proper value of parameter on search page. It is due to - character in parameter.Because when i remove - character from the values then it works properly.

What should i do ?

Thanks !

You can't use a hyphen as a delimiter and expect to be able to match it within the delimited values as well.

Take the following as an example:

bo-b-fred-jam-es-arth-ur

It won't know which ones are your separator hyphens and which ones to count as the actual values.

Choose a different delimiter, or don't match values with a hyphen in them.

Perhaps using an underscore as your delimiter would be more sensible, if you have to match the hyphens within the values:

bo-b_fred_jam-es_arth-ur

Then it will match:

RewriteRule ^([\-0-9a-zA-Z]+)_([\-0-9a-zA-Z]+)_([\-0-9a-zA-Z]+)_([\-0-9a-zA-Z]+)/?$ search_result.php?parrent_prop_type=$1&prop_type_name=$2&location=$3&prop_type_auto_id=$4 [NC]