Can I replace characters?

Topics: Developer Forum
Jul 29, 2009 at 3:46 PM

Hey all,

I have my rewrite rule working no problem but I also wish to replace \. with _dot_


would become

Is this possible? The service I am targeting cannot accept dots in the url parameters.



Jul 29, 2009 at 11:40 PM

yes, easy to do

RewriteRule ^/service/blah/blah/([^\.]+)\.([^\.]+)   /service/blah/blah/$1_dot_$2  

The sequence ([^\.]+) means "a sequence of one or more characters, where each character is any character except dot".   The \. matches the dot. Put it all together and you have two sequences of characters not includeing dot, which are separated by a dot.