We are running an EE site which is successfully stripping the /index.php from the URL using the following rewrite rule:

RewriteCond $1 !^(docs|index.php|sitemap.php) [NC]
RewriteRule ^(.\*)$ /index.php/$1 [L]

I now need to get the site to redirect from the non www (example.com) version to the www. (www.example.com) version of the site. At the moment I've tried:

```
RewriteCond $1 !^(docs|index\.php|sitemap\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

```

This adds the 'www.', but puts the index.php back on all pages of the site. What am I doing wrong?