Trying to combine two htaccess RewriteRules at the same time:
1) transform all non-www URLs to www
2) send all requests to index.php
Number 2 works with
It looks like you just need to add the HTTP_HOST checking before the catch-all rewrite to index.php.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NC]
This redirects to www before any of the URI have been rewritten to the catch-all, then:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA]
Do the catch-all, which happens after the non-www gets 301 redirected to the www domain.