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_

i.e.

http://www.mywebsite.com/service/blah/blah/15.5

would become

http://www.mywebsite.com/service/blah/blah/15_dot_5

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

Regards,

Mark

Coordinator
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.