I have joomla installed on root folder and another joomla installed on subfolder. I want to redirect www to non in subfolder by this code in blog htaccess:
First question/comment: You really need to display the .htaccess in the DocumentRoot AND the subdirectory. Lacking that, I’ll bet that the DocumentRoot (whose .htaccess is executed first) redirects to the www’d domain so that the .htaccess in the blog subdirectory isn’t given a chance.
Workarounds:
Exclude blog from redirects to www in the DocumentRoot’s .htaccess
Make blog the DocumentRoot for the blog.domain.com subdomain (because that will then bypass the domain’s DocumentRoot).
Second question: Why do you find it necessary to group the {HTTP_HOST}? All you need to be testing is the www. What you’ve done is make the {HTTP_HOST} OPTIONAL, i.e., www.mydomain.com OR null (an impossibility on a typical production website).
You might benefit from reading the mod_rewrite tutorial at http://dk.co.nz/seo as it contains explanations and sample code. It’s helped may members and should help you, too.