g1smd - 12:06 am on Feb 23, 2013 (gmt 0)
The rules need to be in a slightly different order.
The non-www to www ruleset should be last. Rather than test for
^example\.com in the Condition, it should test for
!^(www\.example\.com)?$ to ensure all non-canonical requests are redirected.
There's a couple of minor changes to make to the rules.
The rules for index pages each need a preceding
THE_REQUEST otherwise you end up with an infinite loop of redirecting and rewriting. As this question comes up every few days, it should be easy to find the code already posted here.
Add a blank line after each Rule to make the code easier to read.
Don't escape periods in the rule target.
Be consistent. Change