Forum Moderators: phranque
results-jabra-a125-battery.htm
To
search/?searchterm=jabra+a125+battery
where 'jabra-a125-battery' is the search 'phrase'.
The phrase could be of length 'n' i.e. it could be 'jabra-a125'.
The '-' need to be converted to '+'.
If someone could either provide a solution or point me in the right direction i would be greatful.
In the simplest case -rewriting the entire URL to the script filepath- you'd start with the character following the domain name and slash, and stop when you find a period -- or a period followed by ".htm".
In this regard, the length does not matter.
mod_rewrite is very inefficient for 'search and replace' since it has no internal looping or subroutine-calling capability; You would be better off to do this replacement within the script itself, if it is truly required. The other two solutions are to use multiple rules, each rule handling a number of character replacements, say 3, 2, and 1 for a total possible replacement count of six, or to re-start the entire mod_rewrite processing sequence after each replacement (See the [N] flag for RewriteRule). Neither of these solutions is very efficient, and the latter can bring a server to its knees if the .htaccess file is large.
We have several previous threads here on replacing underscores with hyphens and replacing spaces which demonstrate the efficiency problem; They can be found using the WebmasterWorld site search.
Jim