I implemented some code to redirect non-www requests to their www counterpart but this has broken my subdomains. For example, if I visit sub.example.com I am redirected to www.example.com/sub
I need to be able to redirect non-www traffic to www but also be able to use subdomains. Can anyone help me understand how this would be done? Also, if you see any other problems with the way I have implemented this please let me know.
You can either exclude all your known subdomains by adding them to the RewriteCond, or you might elect to redirect only example.com to www.example.com, instead of redirecting anything except www.example.com to www.example.com -- which is what your current code is doing.