I've got a .htaccess redirect for "non www" such as this:

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

it's working. But, i've several subdomains apart from www. Basically call for instance http://shop.example.com it redirects me to: http://www.shop.example.com

I shouldn't write the subdomains in to the .htaccess file, it will work instantly, just ignore other things than www and '' such as this:

if subdomain =='' -> redirect to www.HTTP_HOST....
elseif subdomain !='' && subdomain !='www' -> do nothing.

thanks!

Do this rule:

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And also to also take HTTPS into consideration:

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

do this:

Options +FollowSymlinks

RewriteEngine On

RewriteCond %//s% ^www.(.)//((s)ons.)$ [NC]

RewriteRule ^ http%3://%1% [L,R=301]

Just attempted it with internetagentur.drupal-webmaster.de (the subdomain) - the primary is without www.