I wish to redirect wildcard subdomains towards the file "user_site.php" such as the following :

RewriteCond $1 !^(user_site\.php|home_site\.php    
RewriteCond %{HTTP_HOST} !^(www|mail|ftp)?\.?domain.com [NC]
RewriteRule ^(.*)$ /user_site.php/$1 [L]

but when the subdomain is www or empty , i wish to rewrite it to "home_site.php"

how is this done ? Thanks

I have thought it was already clarified here on stackoverflow , Thanks

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^(.*)/?$ home_site.php/$1 [NC,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^(www|mail).domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+).domain.com$ [NC] 
RewriteRule ^(.*)/?$ user_site.php/$1 [NC,QSA,L]