RewriteRule ^coaching/complete\sin\s\(30\smin,\s1\shour...\)
http://www.example.com/coaching/complete+in+%2830+min-+1+hour...%29-11
Output Expected
http://www.example.com/coaching/complete+in+(30+min-+1+hour...)-11
however it is giving output as
http://www.example.com/coaching/complete+in+830+min-+1+hour...9-11
what is the problem in my code?
the problem is that %2 is actually interpreted by mod_rewrite as a back-reference to the last matched RewriteCond pattern’s second group match.
If there’s no such reference, it’s simply expanded as an empty string.
So you have first to escape the percent characters like this:
However, you also need to use the [NE] flag if you really want those characters to appear as is in the output url, else mod_rewrite will escape them into ‘(‘ and ‘)’.