It should works like this: http: // subdomain.site.com display the content of subdomain.php
This is OK!
http:// WWW .subdomain.site.com/ display the content of the http:// www .site.com WHICH is wrong. I want all www. subdomain.site.com be redirected to www. site.com
If I type http :// subdomain.site.com/category/name_of_category I am redirected to http: // WWW .subdomain.site.com/category/name_of_category and it is diaplyed the content of http: // www. site.com/category/name_of_category Instead of that I need a 404 error response. How can I resolve this problem ?
Host can be exactly www.example.com OR exactly www.example.co. Maybe, but I strongly suspect you mean
<further tangent> Find and read the boilerplate on using "example.com". There are many reasons for it. But auto-linking only kicks in when there's a preceding http:// </further tangent>
http://WWW.subdomain.example.com/ display the content of the http://www.example.com WHICH is wrong. I want all www.subdomain.example.com be redirected to www.site.com
Where is the code that says so?
If I type http://subdomain.example.com/category/name_of_category I am redirected to http://WWW.subdomain.example.com/category/name_of_category
Then there must be additional RewriteRules involved, because-- independent of any hostname issues-- the quoted rule only applies to requests for the root ^$ From the information given, it's impossible to tell whether we're dealing with the results of other rules in the same htaccess, or rules at the host/config level.
By the way, I hope that wasn't a verbatim quote from htaccess, since it would imply that the subdomain rewrite is the very first RewriteRule. It should be one of the last, after any explicit redirects are out of the way.