Recently I found out that I should deicide either I stick with using my domain with www or without it, to avoid duplicate content.

I deicided I would like to go with www prefix

Problem is that most links in google search results don't have www. prefix.

So I went to google webmaster tools and set prefered to www. (both for domain.com and domain.com)

Next I added this to .htacces
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
this works fine when I enter domain.com it automatically gets redirected to www.domain.com

but If I enter address like domain.com/category/item-1
I get redirected to domain.com/index.php

What could I do to fix this ?

Do I need to write redirect for each page, from non-www to www. ?

Google still hasn't added www. to search results.