Forum Moderators: phranque
Please provide clear examples of the problem URLs (using example.com, as above), your desired URLs, the code that you have tried so far, a description of your testing, and the results.
Thanks,
Jim
Before even starting a coded solution, be sure that there are no links anywhere on your site to "www.subdomain.example.com" and if you use Google Webmaster tools, remove any "www/non-www" preference you have set on the GWT Site Configuration->Settings page.
Jim
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.subdomain.example.com) [NC]
RewriteRule ^(.*)$ http://subdomain.example.com/$1 [R=301,L]
[edited by: jdMorgan at 10:54 pm (utc) on June 18, 2009]
[edit reason] example.com [/edit]
Do URLs such as www.subdomain.example.com successfully resolve to your server and serve content?
Jim
[edited by: jdMorgan at 10:53 pm (utc) on June 18, 2009]
Options +FollowSymlinks
RewriteEngine on
#
# Externally redirect to remove "www" prefix from subdomains
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [NC]
RewriteRule ^(.*)$ http://%1.example.com/$1 [R=301,L]
#
# Externally redirect to canonical www subdomain
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Jim